SaveRequest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Http\Requests\Link;
  3. use App\Http\Requests\Request;
  4. use Illuminate\Validation\Rule;
  5. use Illuminate\Database\Query\Builder;
  6. class SaveRequest 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. 'type' => 'required',
  29. 'url' => [
  30. 'required',
  31. Rule::unique('links')->where(function (Builder $query) {
  32. return $query->where('deleted_at', null);
  33. })->ignore($this->route('id'))
  34. ],
  35. 'remark' => 'nullable',
  36. 'tag' => 'nullable',
  37. 'cost' => 'nullable',
  38. 'business_ids' => 'nullable',
  39. 'country' => 'nullable',
  40. 'big_ball' => 'nullable',
  41. 'quantitative_restrictions' => 'nullable',
  42. 'phone_verification' => 'nullable',
  43. 'timed_release' => 'nullable',
  44. 'authority_score' => 'nullable',
  45. 'spam_score' => 'nullable',
  46. 'home_page' => 'nullable',
  47. ];
  48. }
  49. public function attributes()
  50. {
  51. return [
  52. 'type' => '外链类型',
  53. 'url' => '平台链接',
  54. 'remark' => '备注',
  55. 'tag' => '标签',
  56. 'cost' => '费用',
  57. 'business_ids' => '行业',
  58. 'country' => '国家',
  59. 'big_ball' => '锚文本',
  60. 'quantitative_restrictions' => '数量限制',
  61. 'phone_verification' => '手机验证',
  62. 'timed_release' => '定时发布',
  63. 'authority_score' => 'authority score',
  64. 'spam_score' => 'spam score',
  65. 'home_page' => '个人主页加网址',
  66. ];
  67. }
  68. }