mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
feat: added insert songs only to Filament (#776)
This commit is contained in:
@@ -15,4 +15,5 @@ enum ThemeType: int
|
||||
|
||||
case OP = 0;
|
||||
case ED = 1;
|
||||
case IS = 2;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Filament\BulkActions\Base\RestoreBulkAction;
|
||||
use App\Filament\Components\Infolist\TextEntry;
|
||||
use App\Filament\RelationManagers\Base\ActionLogRelationManager;
|
||||
use App\Models\BaseModel;
|
||||
use App\Scopes\WithoutInsertSongScope;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
@@ -213,6 +214,7 @@ abstract class BaseResource extends Resource
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
WithoutInsertSongScope::class,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,8 @@ class Page extends BaseResource
|
||||
->required()
|
||||
->maxLength(16777215)
|
||||
->rules(['required', 'max:16777215'])
|
||||
->columnSpan(2),
|
||||
->columnSpan(2)
|
||||
->formatStateUsing(fn (PageModel $record) => $record->body),
|
||||
])
|
||||
->columns(2);
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ class Theme extends BaseResource
|
||||
$slug = $slug->append($type->name);
|
||||
}
|
||||
|
||||
if ($slug->isNotEmpty()) {
|
||||
if ($slug->isNotEmpty() && $type !== ThemeType::IS) {
|
||||
$sequence = $get(ThemeModel::ATTRIBUTE_SEQUENCE);
|
||||
$slug = $slug->append(strval(empty($sequence) ? 1 : $sequence));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ use Filament\Infolists\Components\Section;
|
||||
use Filament\Infolists\Infolist;
|
||||
use Filament\Resources\RelationManagers\RelationGroup;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* Class Group.
|
||||
@@ -129,19 +128,7 @@ class Group extends BaseResource
|
||||
->helperText(__('filament.fields.group.slug.help'))
|
||||
->required()
|
||||
->maxLength(192)
|
||||
->unique(GroupModel::class, GroupModel::ATTRIBUTE_SLUG, ignoreRecord: true)
|
||||
->rules([
|
||||
fn ($record) => [
|
||||
'required',
|
||||
'max:192',
|
||||
'alpha_dash',
|
||||
$record !== null
|
||||
? Rule::unique(GroupModel::class)
|
||||
->ignore($record->getKey(), GroupModel::ATTRIBUTE_ID)
|
||||
->__toString()
|
||||
: Rule::unique(GroupModel::class)->__toString(),
|
||||
]
|
||||
]),
|
||||
->unique(GroupModel::class, GroupModel::ATTRIBUTE_SLUG, ignoreRecord: true),
|
||||
])
|
||||
->columns(1);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,13 @@ class ArtistSchema extends EloquentSchema implements InteractsWithPivots, Search
|
||||
|
||||
// Undocumented paths needed for client builds
|
||||
new AllowedInclude(new ArtistSchema(), 'groups.songs.artists'),
|
||||
new AllowedInclude(new SongSchema(), 'groups.songs.animethemes.song'),
|
||||
new AllowedInclude(new GroupSchema(), 'groups.songs.animethemes.group'),
|
||||
new AllowedInclude(new ArtistSchema(), 'groups.songs.animethemes.song.artists'),
|
||||
new AllowedInclude(new ImageSchema(), 'groups.songs.animethemes.anime.images'),
|
||||
new AllowedInclude(new EntrySchema(), 'groups.songs.animethemes.animethemeentries'),
|
||||
new AllowedInclude(new VideoSchema(), 'groups.songs.animethemes.animethemeentries.videos'),
|
||||
new AllowedInclude(new AudioSchema(), 'groups.songs.animethemes.animethemeentries.videos.audio'),
|
||||
new AllowedInclude(new ExternalResourceSchema(), 'groups.songs.resources'),
|
||||
new AllowedInclude(new ArtistSchema(), 'songs.artists'),
|
||||
new AllowedInclude(new SongSchema(), 'songs.animethemes.song'),
|
||||
|
||||
@@ -46,11 +46,11 @@ class SynonymController extends BaseController
|
||||
{
|
||||
$query = new Query($request->validated());
|
||||
|
||||
$videos = $query->hasSearchCriteria()
|
||||
$synonyms = $query->hasSearchCriteria()
|
||||
? $action->search($query, $request->schema())
|
||||
: $action->index(AnimeSynonym::query(), $query, $request->schema());
|
||||
|
||||
return new SynonymCollection($videos, $query);
|
||||
return new SynonymCollection($synonyms, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,11 +46,11 @@ class EntryController extends BaseController
|
||||
{
|
||||
$query = new Query($request->validated());
|
||||
|
||||
$videos = $query->hasSearchCriteria()
|
||||
$entries = $query->hasSearchCriteria()
|
||||
? $action->search($query, $request->schema())
|
||||
: $action->index(AnimeThemeEntry::query(), $query, $request->schema());
|
||||
|
||||
return new EntryCollection($videos, $query);
|
||||
return new EntryCollection($entries, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,11 +46,11 @@ class ThemeController extends BaseController
|
||||
{
|
||||
$query = new Query($request->validated());
|
||||
|
||||
$videos = $query->hasSearchCriteria()
|
||||
$themes = $query->hasSearchCriteria()
|
||||
? $action->search($query, $request->schema())
|
||||
: $action->index(AnimeTheme::query(), $query, $request->schema());
|
||||
|
||||
return new ThemeCollection($videos, $query);
|
||||
return new ThemeCollection($themes, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ use App\Models\Wiki\Anime;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
use App\Models\Wiki\Group;
|
||||
use App\Models\Wiki\Song;
|
||||
use App\Scopes\WithoutInsertSongScope;
|
||||
use Database\Factories\Wiki\Anime\AnimeThemeFactory;
|
||||
use Elastic\ScoutDriverPlus\Searchable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -69,6 +70,18 @@ class AnimeTheme extends BaseModel implements InteractsWithSchema
|
||||
final public const RELATION_SYNONYMS = 'anime.animesynonyms';
|
||||
final public const RELATION_VIDEOS = 'animethemeentries.videos';
|
||||
|
||||
/**
|
||||
* The "booting" method of the model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::addGlobalScope(new WithoutInsertSongScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Scopes;
|
||||
|
||||
use App\Enums\Models\Wiki\ThemeType;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Database\Eloquent\Scope;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* Class WithoutInsertSongScope.
|
||||
*/
|
||||
class WithoutInsertSongScope implements Scope
|
||||
{
|
||||
/**
|
||||
* Apply the scope to a given Eloquent query builder.
|
||||
*
|
||||
* @param Builder $builder
|
||||
* @param Model $model
|
||||
* @return void
|
||||
*/
|
||||
public function apply(Builder $builder, Model $model): void
|
||||
{
|
||||
if (Filament::isServing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$builder->whereNot(AnimeTheme::ATTRIBUTE_TYPE, ThemeType::IS->value);
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,7 @@ return [
|
||||
ThemeType::class => [
|
||||
ThemeType::OP->name => 'OP',
|
||||
ThemeType::ED->name => 'ED',
|
||||
ThemeType::IS->name => 'IS',
|
||||
],
|
||||
VideoOverlap::class => [
|
||||
VideoOverlap::NONE->name => 'None',
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -13,7 +13,7 @@ cropperjs/dist/cropper.min.css:
|
||||
|
||||
filepond/dist/filepond.min.css:
|
||||
(*!
|
||||
* FilePond 4.32.5
|
||||
* FilePond 4.32.6
|
||||
* Licensed under MIT, https://opensource.org/licenses/MIT/
|
||||
* Please visit https://pqina.nl/filepond/ for details.
|
||||
*)
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user