app/Http/Requests/UserRequest.php
/**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
Get the validation rules that apply to the request.
@return array
Get the validation rules that apply to the request . @return array
public function rules()
    {
        $user = User::find($this->user);
        switch($this->method())
        {
            case 'GET':
            case 'DELETE':
            {
                return [];
            }
            case 'POST':
            {
                return [
                    'name'     => 'min:5|max:100|required',
                    'email'    => 'min:10|max:120|required|email|unique:users',
                    'password' => 'min:8|max:20|required|confirmed',
                    'type'     => 'required'
                ];
            }
            case 'PUT':
            case 'PATCH':
            {
                return [
                    'name'     => 'min:5|max:100|required',
                    'email'    => 'min:10|max:120|required|email|unique:users,email,'.$user->id,
                    'password' => 'min:8|max:20|confirmed',
                    'type'     => 'required'
                ];
            }
            default:break;
        }
    }
public function rules ( ) { $ user = User :: find ( $ this -> user ) ; switch ( $ this -> method ( ) ) { case 'GET' : case 'DELETE' : { return [ ] ; } case 'POST' : { return [ 'name' => 'min:5|max:100|required' , 'email' => 'min:10|max:120|required|email|unique:users' , 'password' => 'min:8|max:20|required|confirmed' , 'type' => 'required' ] ; } case 'PUT' : case 'PATCH' : { return [ 'name' => 'min:5|max:100|required' , 'email' => 'min:10|max:120|required|email|unique:users,email,' . $ user -> id , 'password' => 'min:8|max:20|confirmed' , 'type' => 'required' ] ; } default : break ; } }
Get the validation rules that apply to the request.
Get the validation rules that apply to the request .