You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
<?php
|
|
|
|
namespace App\Http\Requests\Web\Identity;
|
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
class RoleRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Gate::allows('role.create') || Gate::allows('role.update');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => ['required', 'string'],
|
|
'guard_name' => ['required', 'string'],
|
|
'permissions' => ['array', 'min:1'],
|
|
'permissions.*' => ['required'],
|
|
];
|
|
}
|
|
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'name' => __('domains/identity/field.role.name'),
|
|
'guard_name' => __('domains/identity/field.role.guard_name'),
|
|
'permissions' => __('domains/identity/field.role.permissions'),
|
|
];
|
|
}
|
|
}
|
|
|