34 lines
1.0 KiB
PHP
34 lines
1.0 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Repositories;
|
|
|
|
use App\Contracts\Search;
|
|
use App\Models\ProjectTranslationServiceTextHash;
|
|
use App\Services\Search\CreateSearchInstanceCommand;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
final readonly class ProjectTranslationServiceTextHashRepository
|
|
{
|
|
|
|
public function __construct(
|
|
private CreateSearchInstanceCommand $createSearchInstanceCommand,
|
|
) { }
|
|
|
|
public function getHashes(array $codes, ?array $languages = null): Search
|
|
{
|
|
$query = ProjectTranslationServiceTextHash::query()
|
|
->whereIn('code', $codes)
|
|
->when($languages, function (Builder $query) use ($languages) {
|
|
$query->whereIn('language_id', $languages);
|
|
});
|
|
|
|
return $this->createSearchInstanceCommand->execute($query);
|
|
}
|
|
|
|
public function getHashesByIds(array $ids): Search
|
|
{
|
|
$query = ProjectTranslationServiceTextHash::query()->whereIn('id', $ids);
|
|
return $this->createSearchInstanceCommand->execute($query);
|
|
}
|
|
}
|