File manager - Edit - /var/www/html/spdc/api/app/Rules/ScaleTeamInfoIsRequired.php
Back
<?php namespace App\Rules; use App\Enums\ScaleType; use App\Models\Department; use Illuminate\Contracts\Validation\Rule; class ScaleTeamInfoIsRequired implements Rule { /** * Create a new rule instance. * * @return void */ private string|int $departmentId; public function __construct(string|int $departmentId) { $this->departmentId = $departmentId; } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { $isTeamScale = Department::findOrFail($this->departmentId)->scale_type === ScaleType::EQUIPE->value; $valueIsNotEmpty = !empty($value); if ($isTeamScale) { return $valueIsNotEmpty; } return true; } /** * Get the validation error message. * * @return string */ public function message() { return 'The :attribute field is required.'; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings