Created
March 11, 2016 01:11
-
-
Save sword-jin/d2347827948db0a6b0fd to your computer and use it in GitHub Desktop.
One request for save and update.
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 function rules() | |
| { | |
| $user = User::find($this->users); | |
| switch($this->method()) | |
| { | |
| case 'GET': | |
| case 'DELETE': | |
| { | |
| return []; | |
| } | |
| case 'POST': | |
| { | |
| return [ | |
| 'user.name.first' => 'required', | |
| 'user.name.last' => 'required', | |
| 'user.email' => 'required|email|unique:users,email', | |
| 'user.password' => 'required|confirmed', | |
| ]; | |
| } | |
| case 'PUT': | |
| case 'PATCH': | |
| { | |
| return [ | |
| 'user.name.first' => 'required', | |
| 'user.name.last' => 'required', | |
| 'user.email' => 'required|email|unique:users,email,'.$user->id, | |
| 'user.password' => 'required|confirmed', | |
| ]; | |
| } | |
| default:break; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment