src/Http/Requests/RolesRequest.php
public function rules()
    {
        switch($this->method())
        {
            case 'GET':
            case 'DELETE':
            {
                return [];
            }
            case 'POST':
            {
                return [
                    'name' => 'required|min:3|max:255|unique:roles,name',
                ];
            }
            case 'PUT':
            case 'PATCH':
            {
                $id = $this->route()->roles;
                $role = Role::findOrFail($id);
                return [
                    'name' => 'required|min:3|max:255|unique:roles,name,'.$role->id,
                ];
            }
            default:break;
        }
    }
public function rules()
    {
        switch($this->method())
        {
            case 'GET':
            case 'DELETE':
            {
                return [];
            }
            case 'POST':
            {
                return [
                    'name' => 'required|min:3|max:255|unique:roles,name',
                ];
            }
            case 'PUT':
            case 'PATCH':
            {
                $id = $this->route()->roles;
                $role = Role::findOrFail($id);
                return [
                    'name' => 'required|min:3|max:255|unique:roles,name,'.$role->id,
                ];
            }
            default:break;
        }
    }
public function rules ( ) { switch ( $ this -> method ( ) ) { case 'GET' : case 'DELETE' : { return [ ] ; } case 'POST' : { return [ 'name' => 'required|min:3|max:255|unique:roles,name' , ] ; } case 'PUT' : case 'PATCH' : { $ id = $ this -> route ( ) -> roles ; $ role = Role :: findOrFail ( $ id ) ; return [ 'name' => 'required|min:3|max:255|unique:roles,name,' . $ role -> id , ] ; } default : break ; } }
Get the validation rules that apply to the request.

@return array
Get the validation rules that apply to the request .