%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/loslex/test/app/Http/Requests/
Upload File :
Create Path :
Current File : /www/loslex/test/app/Http/Requests/ContestUpdateRequest.php

<?php

namespace App\Http\Requests;

use App\Enums\ContestLevelEnum;
use App\Enums\ContestPublicationStatusEnum;
use App\Enums\ContestRegistrationEnum;
use App\Rules\ContestDate;
use App\Rules\ContestLevelChange;
use App\Rules\ContestPublication;
use App\Rules\ContestRangemaster;
use App\Rules\ContestRegistrationEnd;
use Carbon\Carbon;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Enum;

class ContestUpdateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
     */
    public function rules(): array
    {
        return [
            'contestname'           => 'required|string|max:255',
            'range_id'              => 'required|integer|exists:ranges,id',
            'date'                  => ['required','date', new ContestDate],
            'published'             => ['required', new Enum(ContestPublicationStatusEnum::class), new ContestPublication],
            'contest_level_id'      => ['required', 'exists:contest_levels,id'], //, new ContestLevelChange],
            'contest_category_id'   => 'bail|required_unless:contest_level_id,' . ContestLevelEnum::NOSHOOT->value . '|exists:contest_categories,id',
            'registration_type'     => 'required|integer',
            'registration_start'    => 'bail|required_if:registration_type,=,' . ContestRegistrationEnum::ONLINE->value . '|nullable|date|before:date',
            'registration_end'      => ['bail','required_if:registration_type,=,' . ContestRegistrationEnum::ONLINE->value,'nullable','date',new ContestRegistrationEnd,'after:registration_start'],
            'offsiteregurl'         => 'required_if:registration_type,' . ContestRegistrationEnum::OFFSITE->value,
            'organizeremail'        => 'nullable|email:rfc,dns',

            'organizer_group_id'    => 'required|integer|exists:organizer_groups,id',
            'director_id'           => 'bail|required_unless:contest_level_id,' . ContestLevelEnum::NOSHOOT->value . '|integer|exists:users,id',
            'rangemaster_id'        => [new ContestRangemaster],
            'calibrationwpn'        => ['bail', 'required_unless:contest_level_id,' . ContestLevelEnum::NOSHOOT->value, 'max:255'],
            'caliberlimit'          => 'nullable|string|max:255',

            'instructions'          => 'required',
            'legend'                => 'nullable|string',
            'restrictionstext'      => 'nullable|string',
            'partners'              => 'nullable|string',

            'feelex'                => 'required|integer|min:0|lte:feeothers',
            'feeothers'             => 'required|integer|min:0',
            'protestdeposit'        => 'required|integer|min:0',
            'accountnumber'         => ['nullable','regex:/^(\d{2,6}-)?\d{2,10}\/\d{4}$/'],
            'accvarsym'             => ['nullable','digits_between:1,10'],
            'accnote'               => ['nullable','required_with:accountnumber','regex:/^[[:alnum:] $%*+-.\/:]+$/u'],
            'acccondition'          => 'nullable|string',

            'stages'                => 'required|integer|min:1',
            'squads'                => 'required|integer|min:1',
            'capacity'              => 'required|integer|min:1|gte:squads',
            'distribution'          => ['required', Rule::in(['asc','desc'])],

            'secretstages'          => 'required|boolean',
            'flashlight'            => 'required|integer',
            'toilet'                => 'required|boolean',
            'canteen'               => 'required|boolean',

            'presentation_start.0'  => 'exclude_if:squadshootstyle,manual|required|date_format:H:i',
            'presentation_end.0'    => 'exclude_if:squadshootstyle,manual|required|date_format:H:i',
            'contest_start.0'       => 'exclude_if:squadshootstyle,manual|required|date_format:H:i',
            'contest_end.0'         => 'exclude_if:squadshootstyle,manual|required|date_format:H:i',

            'presentation_start.1'  => 'exclude_if:squadshootstyle,together|required|date_format:H:i',
            'presentation_end.1'    => 'exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_start.1'       => 'exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_end.1'         => 'exclude_if:squadshootstyle,together|required|date_format:H:i',

            'presentation_start.2'  => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'presentation_end.2'    => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_start.2'       => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_end.2'         => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',

            'presentation_start.3'  => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'presentation_end.3'    => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_start.3'       => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_end.3'         => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',

            'presentation_start.4'  => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'presentation_end.4'    => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_start.4'       => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_end.4'         => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',

            'presentation_start.5'  => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'presentation_end.5'    => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_start.5'       => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_end.5'         => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',

            'presentation_start.6'  => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'presentation_end.6'    => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_start.6'       => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_end.6'         => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',

            'presentation_start.7'  => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'presentation_end.7'    => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_start.7'       => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_end.7'         => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',

            'presentation_start.8'  => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'presentation_end.8'    => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_start.8'       => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_end.8'         => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',

            'presentation_start.9'  => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'presentation_end.9'    => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_start.9'       => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_end.9'         => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',

            'presentation_start.10' => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'presentation_end.10'   => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_start.10'      => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
            'contest_end.10'        => 'sometimes|exclude_if:squadshootstyle,together|required|date_format:H:i',
        ];
    }
}

Zerion Mini Shell 1.0