%PDF- %PDF-
Direktori : /www/loslex/test/app/Rules/ |
Current File : /www/loslex/test/app/Rules/ContestRangemaster.php |
<?php namespace App\Rules; use Closure; use App\Models\User; use Illuminate\Contracts\Validation\DataAwareRule; use Illuminate\Contracts\Validation\ValidationRule; class ContestRangemaster implements DataAwareRule,ValidationRule { /** * All of the data under validation. * @var array<string, mixed> */ protected $data = []; /** * Set the data under validation. * @param array<string, mixed> $data */ public function setData(array $data): static { $this->data = $data; return $this; } /** * Run the validation rule. * * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail */ public function validate(string $attribute, mixed $value, Closure $fail): void { if ($value == 0) { return; } // Will be appointed if ($value > 0) { // user_id $rmaster = User::where('id', $value)->get(); if ($rmaster->count() == 0) { $fail('validation.rangemaster_id')->translate(); } // TODO in future we'll test here the user is valid referree } } } // 'required_unless:contest_level_id,' . ContestLevelEnum::NOSHOOT->value . '|integer|exists:users,id'