UpdateAiModelRequest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Http\Requests;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class UpdateAiModelRequest 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. // 真正的鉴权在 AiModelController::update():需要拿到 $aiModel 才能判 owner
  14. return true;
  15. }
  16. /**
  17. * Get the validation rules that apply to the request.
  18. *
  19. * 全部字段用 sometimes:update 是增量的,未提交的字段保持原值。
  20. *
  21. * @return array
  22. */
  23. public function rules()
  24. {
  25. return [
  26. 'name' => ['sometimes', 'required', 'string', 'max:64'],
  27. 'description' => ['sometimes', 'nullable', 'string'],
  28. 'system_prompt' => ['sometimes', 'nullable', 'string'],
  29. 'url' => ['sometimes', 'nullable', 'string', 'max:1024'],
  30. 'model' => ['sometimes', 'nullable', 'string', 'max:1024'],
  31. 'key' => ['sometimes', 'nullable', 'string', 'max:1024'],
  32. 'privacy' => ['sometimes', 'required', 'string', 'in:private,public,disable'],
  33. ];
  34. }
  35. }