Created
October 14, 2014 21:44
-
-
Save alesanabv/65bb8a80249b2d4b2d18 to your computer and use it in GitHub Desktop.
Crud
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function takeAndSkip($take = 10, $skip = 0) | |
{ | |
return self::orderBy('id', 'DESC') | |
->take($take)->skip($skip)->get(); | |
} | |
public static function store($data) | |
{ | |
$validator = Validator::make($data, self::$rules); | |
if ($validator->passes()) { | |
$model = self::create($data); | |
return $model; | |
} | |
return $validator->messages(); | |
} | |
public static function find_and_update($id = null, $data) | |
{ | |
$validator = Validator::make($data, self::$rules); | |
if ($validator->passes()) { | |
$model = self::find($id); | |
$model->update($data); | |
return $model; | |
} | |
return $validator->messages(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment