32 lines
733 B
PHP
32 lines
733 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use App\Models\Project;
|
|
use App\Models\ProjectReport;
|
|
|
|
class AllMergedTiffsPresentRule implements ValidationRule
|
|
{
|
|
protected Project $project;
|
|
|
|
public function __construct(Project $project)
|
|
{
|
|
$this->project = $project;
|
|
}
|
|
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
try {
|
|
$this->project->allMergedTiffsPresent(
|
|
$this->project->getMergedTiffList(),
|
|
Project::getAllDatesOfWeeksInYear($value['year'], $value['week'])
|
|
);
|
|
} catch (\Exception $e) {
|
|
$fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
}
|