CreateOrUpdateRequest.php 896 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Http\Requests\API\RequirementGroup;
  3. use App\Http\Requests\RuleHelper;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. use Illuminate\Validation\Rule;
  6. /**
  7. */
  8. class CreateOrUpdateRequest extends FormRequest
  9. {
  10. use RuleHelper;
  11. /**
  12. * Determine if the user is authorized to make this request.
  13. */
  14. public function authorize(): bool
  15. {
  16. return true;
  17. }
  18. /**
  19. * Get the validation rules that apply to the request.
  20. *
  21. * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
  22. */
  23. public function rules(): array
  24. {
  25. return [
  26. 'asset_id' => [
  27. 'required',
  28. Rule::exists('assets', 'id')->where($this->userCompanyWhere()),
  29. ],
  30. 'name' => 'required|max:255',
  31. 'abbr_name' => 'required|max:30',
  32. ];
  33. }
  34. }