Is it to Recommended to write Insert/Update/Delete Authorization code in same Request class?

Viewed 429

I am writing the below code in Request Class for Validation and Authorization. So the Below code is for add/Update record.

<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class UserRequest extends Request
{
    public function authorize()
    {
        return \Auth::user()->isAdmin();
    }

    public function rules()
    {
        return [
            'UserName' => 'required|max:50|min:3|unique:tbluser,UserName,' . 
                                                     \Request::get( 'UserID' ) . ',UserID',
        ];
    }
}

My question is: Should I write the code to check if the current user is authorized or not to delete the record. For that should I use same Request class that is used for Add/Update or an another class specially for delete authentication? If I use same class then rules() will be executed which are meant for add/update

3 Answers
Related