AgentCustomerSaveRequest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Http\Requests\Sell;
  3. use App\Http\Requests\Request;
  4. use Illuminate\Database\Query\Builder;
  5. use Illuminate\Validation\Rule;
  6. class AgentCustomerSaveRequest extends Request
  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 true;
  16. }
  17. /**
  18. * Get the validation rules that apply to the request.
  19. *
  20. * @return array
  21. */
  22. public function rules()
  23. {
  24. if (!$this->ajax()) {
  25. return [];
  26. }
  27. return [
  28. 'customer_name' => [
  29. 'required',
  30. Rule::unique('agent_customer')->where(function (Builder $query) {
  31. return $query->where('deleted_at', null);
  32. })->ignore($this->route('id'))
  33. ],
  34. 'domain' => 'required',
  35. 'contact_user' => 'required',
  36. 'contact_phone' => 'required',
  37. 'user_id' => 'nullable',
  38. 'remark' => 'nullable',
  39. ];
  40. }
  41. public function attributes()
  42. {
  43. return [
  44. 'customer_name' => '客户名称',
  45. 'domain' => '域名',
  46. 'contact_user' => '联系人',
  47. 'contact_phone' => '联系方式',
  48. ];
  49. }
  50. }