ERP-API/app/Http/Requests/Auth/Permission/ListRequest.php

40 lines
1.0 KiB
PHP

<?php
namespace App\Http\Requests\Auth\Permission;
use Illuminate\Foundation\Http\FormRequest;
class ListRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return auth()->user()->checkPermission("auth.role:read");
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'limit' => 'nullable',
'offset' => 'nullable',
'search' => 'nullable',
'filter' => 'nullable|array',
'filter.*.column' => 'required|in:name,email',
'filter.*.operator' => 'nullable|in:eq,in',
'filter.*.query' => 'required',
'sort' => 'nullable|array',
'sort.column' => 'nullable|in:name,email',
'sort.dir' => 'nullable',
];
}
}