StoreReclamationSparePartsRequest.php 785 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Http\Requests;
  3. use App\Models\Role;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. class StoreReclamationSparePartsRequest extends FormRequest
  6. {
  7. /**
  8. * Determine if the user is authorized to make this request.
  9. */
  10. public function authorize(): bool
  11. {
  12. return in_array(auth()->user()?->role, [Role::ADMIN, Role::MANAGER]);
  13. }
  14. /**
  15. * Get the validation rules that apply to the request.
  16. *
  17. * @return array
  18. */
  19. public function rules(): array
  20. {
  21. return [
  22. 'rows' => 'nullable|array',
  23. 'rows.*.spare_part_id' => 'nullable|integer|exists:spare_parts,id',
  24. 'rows.*.quantity' => 'nullable|integer|min:0',
  25. 'rows.*.with_documents' => 'nullable',
  26. ];
  27. }
  28. }