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