| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- declare(strict_types=1);
- namespace App\Http\Requests;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Validation\Rule;
- class CreateProductionOrderReclamationRequest extends FormRequest
- {
- public function authorize(): bool
- {
- return $this->user()?->hasPermission('reclamations.create') === true
- && $this->user()?->hasPermission('schedule-orders.view') === true;
- }
- /** @return array<string, mixed> */
- public function rules(): array
- {
- $productionOrderId = (int) $this->route('productionOrder')?->getKey();
- return [
- 'item_ids' => ['required', 'array', 'min:1'],
- 'item_ids.*' => [
- 'required',
- 'integer',
- 'distinct',
- Rule::exists('production_order_items', 'id')->where(
- static fn ($query) => $query
- ->where('production_order_id', $productionOrderId)
- ->whereNull('deleted_at'),
- ),
- ],
- 'nav' => ['nullable', 'string', 'max:100'],
- ];
- }
- }
|