diff --git a/src/Http/Requests/StorePermissionRequest.php b/src/Http/Requests/StorePermissionRequest.php index cd5b563..9359c2d 100644 --- a/src/Http/Requests/StorePermissionRequest.php +++ b/src/Http/Requests/StorePermissionRequest.php @@ -2,6 +2,7 @@ namespace Fintech\Auth\Http\Requests; +use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rule; @@ -22,8 +23,10 @@ public function authorize(): bool */ public function rules(): array { + $uniqueRule = 'unique:' . config('fintech.auth.permission_model', \Fintech\Auth\Models\Permission::class) . ',name'; + return [ - 'name' => ['required', 'string', 'min:5', 'max:255'], + 'name' => ['required', 'string', 'min:5', 'max:255', $uniqueRule], 'guard_name' => ['required', 'string', Rule::in(array_keys(config('auth.guards', ['web', 'api'])))], ]; }