CreateOrUpdateRequest.php 829 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Http\Requests\API\Role;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. use Illuminate\Validation\Rule;
  5. class CreateOrUpdateRequest extends FormRequest
  6. {
  7. /**
  8. * Determine if the user is authorized to make this request.
  9. */
  10. public function authorize(): bool
  11. {
  12. return true;
  13. }
  14. /**
  15. * Get the validation rules that apply to the request.
  16. *
  17. * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
  18. */
  19. public function rules(): array
  20. {
  21. return [
  22. 'name' => [
  23. 'required',
  24. 'max:100',
  25. Rule::unique('roles')
  26. ->where("guard_name", 'api')
  27. ->ignore($this->route()->parameter('role')),
  28. ],
  29. ];
  30. }
  31. }