lundi 4 janvier 2016

Is that possible to have multiple rules function in single Request class?

I have request class like below.

class CategoryRequest extends Request
{
    public function response(array $errors){
        return \Redirect::back()->withErrors($errors)->withInput();
    }

    public function authorize()
    {
        return false;
    }

    public function rules()
    {
        return [
            'Category' => 'required|unique:tblcategory|max:25|min:5'
        ];
    }
}

There is rules function.

In the controller, there are multiple methods that have Request as a Parameter. Most of them vary in the validation point of view. I mean, if I am admin,. I can update 4 fields. If I am manager, I can update 3 and if I am normal user, I can update 2. So validation will change according to roles.

Is that possible to have multiple rules function in Request class ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1OvBEs0
via IFTTT

Aucun commentaire:

Enregistrer un commentaire