StoreSparePartOrderRequest.php 999 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Http\Requests;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class StoreSparePartOrderRequest extends FormRequest
  5. {
  6. /**
  7. * Determine if the user is authorized to make this request.
  8. */
  9. public function authorize(): bool
  10. {
  11. return hasRole('admin,manager');
  12. }
  13. /**
  14. * Get the validation rules that apply to the request.
  15. *
  16. * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
  17. */
  18. public function rules(): array
  19. {
  20. return [
  21. 'spare_part_id' => 'required|exists:spare_parts,id',
  22. 'source_text' => 'nullable|string|max:255',
  23. 'sourceable_id' => 'nullable|integer',
  24. 'sourceable_type' => 'nullable|string',
  25. 'status' => 'required|in:ordered,in_stock,shipped',
  26. 'ordered_quantity' => 'required|integer|min:1',
  27. 'with_documents' => 'boolean',
  28. 'note' => 'nullable|string',
  29. ];
  30. }
  31. }