mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-09-04 03:35:02 +02:00
62 lines
1.5 KiB
PHP
62 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Tabs\Studio;
|
|
|
|
use App\Enums\Models\Wiki\ResourceSite;
|
|
use App\Filament\Tabs\BaseTab;
|
|
use App\Models\Wiki\Studio;
|
|
use App\Models\Wiki\ExternalResource;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
/**
|
|
* Class StudioResourceTab.
|
|
*/
|
|
abstract class StudioResourceTab extends BaseTab
|
|
{
|
|
/**
|
|
* The resource site.
|
|
*
|
|
* @return ResourceSite
|
|
*/
|
|
abstract protected static function site(): ResourceSite;
|
|
|
|
/**
|
|
* Get the displayable name of the tab.
|
|
*
|
|
* @return string
|
|
*
|
|
* @noinspection PhpMissingParentCallCommonInspection
|
|
*/
|
|
public function getLabel(): string
|
|
{
|
|
return __('filament.tabs.studio.resources.name', ['site' => static::site()->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_RESOURCES, function (Builder $resourceQuery) {
|
|
$resourceQuery->where(ExternalResource::ATTRIBUTE_SITE, static::site()->value);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get the badge for the tab.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function getBadge(): int
|
|
{
|
|
return Studio::query()->whereDoesntHave(Studio::RELATION_RESOURCES, function (Builder $resourceQuery) {
|
|
$resourceQuery->where(ExternalResource::ATTRIBUTE_SITE, static::site()->value);
|
|
})->count();
|
|
}
|
|
}
|