| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- declare(strict_types=1);
- namespace App\Http\Requests;
- use App\Models\Role;
- use Illuminate\Database\Query\Builder;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Validation\Rule;
- class SaveProductionOrderInstallationRequest extends FormRequest
- {
- public function authorize(): bool
- {
- return true;
- }
- /** @return array<string, mixed> */
- public function rules(): array
- {
- return [
- 'installation_date' => ['required', 'date'],
- 'installation_days' => ['required', 'integer', 'min:1', 'max:365'],
- 'brigadier_id' => [
- 'required',
- 'integer',
- Rule::exists('users', 'id')->where(
- fn (Builder $query): Builder => $query
- ->where('role', Role::BRIGADIER)
- ->whereNull('deleted_at'),
- ),
- ],
- 'note' => ['nullable', 'string', 'max:10000'],
- 'nav' => ['nullable', 'string', 'max:100'],
- ];
- }
- /** @return array<string, string> */
- public function attributes(): array
- {
- return [
- 'installation_date' => 'дата монтажа',
- 'installation_days' => 'количество дней монтажа',
- 'brigadier_id' => 'бригадир',
- ];
- }
- }
|