UserRequest.php 781 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Http\Requests;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class UserRequest extends FormRequest
  5. {
  6. /**
  7. * Determine if the user is authorized to make this request.
  8. *
  9. * @return bool
  10. */
  11. public function authorize()
  12. {
  13. return true;
  14. }
  15. /**
  16. * Get the validation rules that apply to the request.
  17. *
  18. * @return array
  19. */
  20. public function rules()
  21. {
  22. $id = (int) optional($this->route('user'))->id;
  23. return [
  24. //
  25. 'mobile' => 'max:12|unique:users,mobile,'.$id,
  26. 'card_id' => 'max:20',
  27. 'remark' => 'sometimes'
  28. ];
  29. }
  30. public function attributes()
  31. {
  32. return [
  33. 'mobile' => '手机号',
  34. ];
  35. }
  36. }