SettingUpdateRequest.php 791 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Api\v1\Requests;
  3. use App\Rules\IsValideEmailList;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. use Illuminate\Support\Facades\Auth;
  6. class SettingUpdateRequest extends FormRequest
  7. {
  8. /**
  9. * Determine if the user is authorized to make this request.
  10. *
  11. * @return bool
  12. */
  13. public function authorize()
  14. {
  15. return Auth::check();
  16. }
  17. /**
  18. * Get the validation rules that apply to the request.
  19. *
  20. * @return array
  21. */
  22. public function rules()
  23. {
  24. $rule = [
  25. 'value' => [
  26. 'required',
  27. ],
  28. ];
  29. if ($this->route()?->parameter('settingName') == 'restrictList') {
  30. $rule['value'][] = new IsValideEmailList;
  31. }
  32. return $rule;
  33. }
  34. }