ldc-cocotte/app/Cqs/Queries/PickupExceptions/HasAutoUpdatedPickupExceptionsForYearQuery.php

34 lines
883 B
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
namespace App\Cqs\Queries\PickupExceptions;
use App\Contracts\Query;
use App\Contracts\QueryInput;
use App\Models\PickupException;
use Webmozart\Assert\Assert;
/**
* @implements \App\Contracts\Query<
* \App\Cqs\Queries\PickupExceptions\HasAutoUpdatedPickupExceptionsForYearQueryInput,
* bool
* >
*/
final readonly class HasAutoUpdatedPickupExceptionsForYearQuery implements Query
{
/**
* @param \App\Cqs\Queries\PickupExceptions\HasAutoUpdatedPickupExceptionsForYearQueryInput $input
*/
#[\Override]
public function __invoke(QueryInput $input): bool
{
Assert::isInstanceOf($input, HasAutoUpdatedPickupExceptionsForYearQueryInput::class);
return PickupException::query()
->whereYear('date', $input->year)
->where('auto_updated', true)
->exists();
}
}