mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-09-04 03:35:02 +02:00
62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Tabs\Studio;
|
|
|
|
use App\Enums\Models\Wiki\ImageFacet;
|
|
use App\Filament\Tabs\BaseTab;
|
|
use App\Models\Wiki\Studio;
|
|
use App\Models\Wiki\Image;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
/**
|
|
* Class StudioImageTab.
|
|
*/
|
|
abstract class StudioImageTab extends BaseTab
|
|
{
|
|
/**
|
|
* The image facet.
|
|
*
|
|
* @return ImageFacet
|
|
*/
|
|
abstract protected static function facet(): ImageFacet;
|
|
|
|
/**
|
|
* Get the displayable name of the tab.
|
|
*
|
|
* @return string
|
|
*
|
|
* @noinspection PhpMissingParentCallCommonInspection
|
|
*/
|
|
public function getLabel(): string
|
|
{
|
|
return __('filament.tabs.studio.images.name', ['facet' => static::facet()->localize()]);
|
|
}
|
|
|
|
/**
|
|
* The query used to refine the models for the tab.
|
|
*
|
|
* @param Builder $query
|
|
* @return Builder
|
|
*/
|
|
public function modifyQuery(Builder $query): Builder
|
|
{
|
|
return $query->whereDoesntHave(Studio::RELATION_IMAGES, function (Builder $imageQuery) {
|
|
$imageQuery->where(Image::ATTRIBUTE_FACET, static::facet()->value);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get the badge for the tab.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function getBadge(): int
|
|
{
|
|
return Studio::query()->whereDoesntHave(Studio::RELATION_IMAGES, function (Builder $imageQuery) {
|
|
$imageQuery->where(Image::ATTRIBUTE_FACET, static::facet()->value);
|
|
})->count();
|
|
}
|
|
}
|