BatchCreateRequest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Http\Requests\API\Requirement;
  3. use App\Http\Requests\RuleHelper;
  4. use App\Models\Enums\RequirementStatus;
  5. use App\Models\User;
  6. use Illuminate\Foundation\Http\FormRequest;
  7. use Illuminate\Support\Facades\Auth;
  8. use Illuminate\Validation\Rule;
  9. use Illuminate\Validation\Rules\Enum;
  10. class BatchCreateRequest extends FormRequest
  11. {
  12. use RuleHelper;
  13. /**
  14. * Determine if the user is authorized to make this request.
  15. */
  16. public function authorize(): bool
  17. {
  18. return true;
  19. }
  20. /**
  21. * Get the validation rules that apply to the request.
  22. *
  23. * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
  24. */
  25. public function rules(): array
  26. {
  27. return [
  28. '*.title' => 'required|max:255',
  29. '*.asset_id' => [
  30. 'required',
  31. Rule::exists('assets', 'id')->where($this->userCompanyWhere()),
  32. ],
  33. '*.priority' => 'required|in:1,2,3,4',
  34. '*.requirement_group_id' => [
  35. 'required',
  36. Rule::exists('requirement_groups', 'id')->where($this->userCompanyWhere()),
  37. ]
  38. ];
  39. }
  40. }