Skip to content
kaythinks edited this page Apr 5, 2020 · 17 revisions

The Model class has a couple of methods namely ,


public function getDBType(array $data, string $key) : string

This method has a public access modifier hence it can only be accessed by instantiating the Model class. It is used for declaring column types when migrating a table.


public static function create($request) : string

This method is used for creating data in the database by passing the request object as an argument e.g User::create($request).


public static function createAuth($request) : bool

This method is used for creating data in the database by passing the request object as an argument e.g User::createAuth($request).


public static function all() : array

This method is for retrieving all the table data from the database e.g User::all()


public static function find($id) : array

This method is for retrieving a single data by passing the id as an argument e.g User::find(11)


public static function where($query,$data)

This method is for retrieving a single data by passing arguments e.g User::where('email',$request->get('email'))


public static function checkWhere($query,$data) : array

This method is used to check where a value exists in the table column e.g** $filePath::checkWhere($key,$request[$key])** where $key is the table attribute name and $request[$key] is the key value. User::checkWhere('email','demo@demo.com')


public static function update($request) : bool This method is for updating the database by passing the request object as an argument. e.g User::update($request)


public static function delete($request) : bool

This method is for deleting data from the database by passing a request object as an argument e.g User::delete($request)


public static function rawQueryGetOne(string $query) : array

This method is for retrieving a single data from the database by passing raw sql as an argument e.g User:rawQueryGetOne('select from users where id = 11')


public static function rawQueryGetAll(string $query) : array

This method is for retrieving all data from the database by passing raw sql as an argument e.g User:rawQueryGetAll('select * from users')


Clone this wiki locally