diff --git a/app/Concerns/Filament/Actions/HasActionLogs.php b/app/Concerns/Filament/Actions/HasActionLogs.php index 428d11960..6f6b0a5d4 100644 --- a/app/Concerns/Filament/Actions/HasActionLogs.php +++ b/app/Concerns/Filament/Actions/HasActionLogs.php @@ -84,6 +84,10 @@ public function updateLog(Model $relatedModel, Model $pivot): void public function failedLog(Throwable|string|null $exception): void { $this->actionLog->failed($exception); + + // Filament notifications + $this->failureNotificationTitle(Str::limit($exception, 200)); + $this->failure(); } /** @@ -95,6 +99,9 @@ public function finishedLog(): void { if (!$this->isFailedLog()) { $this->actionLog->finished(); + + // Filament notifications + $this->success(); } } @@ -117,4 +124,6 @@ public function isFailedLog(): bool { return $this->actionLog->isFailed(); } + + } diff --git a/app/Filament/Actions/BaseAction.php b/app/Filament/Actions/BaseAction.php index 807aa6cba..c2297a109 100644 --- a/app/Filament/Actions/BaseAction.php +++ b/app/Filament/Actions/BaseAction.php @@ -28,15 +28,14 @@ protected function setUp(): void parent::setUp(); $this->requiresConfirmation(); + $this->failure(); - $this->afterFormValidated(function (BaseAction $action, $livewire) { + $this->before(function (BaseAction $action) { $this->createActionLog($action); - $livewire->dispatch('updateAllRelationManager'); }); - $this->after(function ($livewire) { + $this->after(function () { $this->finishedLog(); - $livewire->dispatch('updateAllRelationManager'); }); $this->modalWidth(MaxWidth::FourExtraLarge); diff --git a/app/Filament/Actions/Models/Wiki/Anime/BackfillAnimeAction.php b/app/Filament/Actions/Models/Wiki/Anime/BackfillAnimeAction.php index ea79d14c8..f45b9934a 100644 --- a/app/Filament/Actions/Models/Wiki/Anime/BackfillAnimeAction.php +++ b/app/Filament/Actions/Models/Wiki/Anime/BackfillAnimeAction.php @@ -27,7 +27,6 @@ use Filament\Forms\Form; use Filament\Notifications\Actions\Action as NotificationAction; use Filament\Notifications\Notification; -use Filament\Support\Enums\MaxWidth; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; @@ -66,8 +65,6 @@ protected function setUp(): void $this->label(__('filament.actions.anime.backfill.name')); $this->icon('heroicon-o-bars-4'); - $this->modalWidth(MaxWidth::FourExtraLarge); - $this->authorize('create', Anime::class); $this->action(fn (Anime $record, array $data) => $this->handle($record, $data)); diff --git a/app/Filament/BulkActions/BaseBulkAction.php b/app/Filament/BulkActions/BaseBulkAction.php index bca44935b..b5da040f4 100644 --- a/app/Filament/BulkActions/BaseBulkAction.php +++ b/app/Filament/BulkActions/BaseBulkAction.php @@ -6,7 +6,6 @@ use App\Concerns\Filament\Actions\HasActionLogs; use App\Models\BaseModel; -use Filament\Forms\Form; use Filament\Support\Enums\MaxWidth; use Filament\Tables\Actions\BulkAction; use Illuminate\Database\Eloquent\Collection; diff --git a/app/Filament/Components/Fields/Slug.php b/app/Filament/Components/Fields/Slug.php new file mode 100644 index 000000000..dda1b3c19 --- /dev/null +++ b/app/Filament/Components/Fields/Slug.php @@ -0,0 +1,40 @@ +required(); + $this->unique(ignoreRecord: true); + $this->rules([ + fn (?Model $record) => [ + 'required', + 'max:192', + 'alpha_dash', + $record !== null + ? Rule::unique($record::class, $this->getName()) + ->ignore($record->getKey(), $record->getKeyName()) + ->__toString() + : Rule::unique($this->getModel(), $this->getName())->__toString(), + ], + ]); + } +} diff --git a/app/Filament/HeaderActions/BaseHeaderAction.php b/app/Filament/HeaderActions/BaseHeaderAction.php index 864bbbbdc..df8795f82 100644 --- a/app/Filament/HeaderActions/BaseHeaderAction.php +++ b/app/Filament/HeaderActions/BaseHeaderAction.php @@ -28,7 +28,7 @@ protected function setUp(): void $this->requiresConfirmation(); - $this->afterFormValidated(function (BaseHeaderAction $action, $livewire) { + $this->before(function (BaseHeaderAction $action, $livewire) { $this->createActionLog($action); $livewire->dispatch('updateAllRelationManager'); }); diff --git a/app/Filament/Resources/Admin/ActionLog.php b/app/Filament/Resources/Admin/ActionLog.php index 0e34978da..495353985 100644 --- a/app/Filament/Resources/Admin/ActionLog.php +++ b/app/Filament/Resources/Admin/ActionLog.php @@ -98,18 +98,6 @@ public static function getRecordSlug(): string return 'action-logs'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return ActionLogModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Admin/Announcement.php b/app/Filament/Resources/Admin/Announcement.php index 3b093616b..3d79410a4 100644 --- a/app/Filament/Resources/Admin/Announcement.php +++ b/app/Filament/Resources/Admin/Announcement.php @@ -91,18 +91,6 @@ public static function getRecordSlug(): string return 'announcements'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return AnnouncementModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Admin/Dump.php b/app/Filament/Resources/Admin/Dump.php index 072da29f0..4f25eb82c 100644 --- a/app/Filament/Resources/Admin/Dump.php +++ b/app/Filament/Resources/Admin/Dump.php @@ -96,18 +96,6 @@ public static function getRecordSlug(): string return 'dumps'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return DumpModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Admin/Feature.php b/app/Filament/Resources/Admin/Feature.php index 58da9b96c..5bc30fa17 100644 --- a/app/Filament/Resources/Admin/Feature.php +++ b/app/Filament/Resources/Admin/Feature.php @@ -93,18 +93,6 @@ public static function getRecordSlug(): string return 'features'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return FeatureModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Admin/FeaturedTheme.php b/app/Filament/Resources/Admin/FeaturedTheme.php index 4bcc9869d..848d53c0d 100644 --- a/app/Filament/Resources/Admin/FeaturedTheme.php +++ b/app/Filament/Resources/Admin/FeaturedTheme.php @@ -105,18 +105,6 @@ public static function getRecordSlug(): string return 'featured-themes'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return FeaturedThemeModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Auth/Permission.php b/app/Filament/Resources/Auth/Permission.php index 3efe24dde..8e0beaa8a 100644 --- a/app/Filament/Resources/Auth/Permission.php +++ b/app/Filament/Resources/Auth/Permission.php @@ -96,18 +96,6 @@ public static function getRecordSlug(): string return 'permissions'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return PermissionModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Auth/Role.php b/app/Filament/Resources/Auth/Role.php index 3383ca7a8..7f8278818 100644 --- a/app/Filament/Resources/Auth/Role.php +++ b/app/Filament/Resources/Auth/Role.php @@ -104,18 +104,6 @@ public static function getRecordSlug(): string return 'roles'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return RoleModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Auth/User.php b/app/Filament/Resources/Auth/User.php index a4b03daa5..6f9d5c09c 100644 --- a/app/Filament/Resources/Auth/User.php +++ b/app/Filament/Resources/Auth/User.php @@ -101,18 +101,6 @@ public static function getRecordSlug(): string return 'users'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return UserModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/BaseResource.php b/app/Filament/Resources/BaseResource.php index bdd0d9c50..78e6e1791 100644 --- a/app/Filament/Resources/BaseResource.php +++ b/app/Filament/Resources/BaseResource.php @@ -43,6 +43,21 @@ public static function canGloballySearch(): bool return false; } + /** + * Get the route key for the resource. + * + * @return string + * + * @noinspection PhpMissingParentCallCommonInspection + */ + public static function getRecordRouteKeyName(): string + { + /** @var Model */ + $model = static::getModel(); + + return (new $model)->getKeyName(); + } + /** * The index page of the resource. * diff --git a/app/Filament/Resources/Discord/DiscordThread.php b/app/Filament/Resources/Discord/DiscordThread.php index a04d23a52..a93b5e140 100644 --- a/app/Filament/Resources/Discord/DiscordThread.php +++ b/app/Filament/Resources/Discord/DiscordThread.php @@ -113,18 +113,6 @@ public static function getRecordSlug(): string return 'discord-thread'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return DiscordThreadModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Document/Page.php b/app/Filament/Resources/Document/Page.php index 771b2e1c9..eecddc4c5 100644 --- a/app/Filament/Resources/Document/Page.php +++ b/app/Filament/Resources/Document/Page.php @@ -7,6 +7,7 @@ use App\Enums\Http\Api\Filter\ComparisonOperator; use App\Filament\Components\Columns\TextColumn; use App\Filament\Components\Fields\Select; +use App\Filament\Components\Fields\Slug; use App\Filament\Components\Infolist\TextEntry; use App\Filament\Resources\BaseResource; use App\Filament\Resources\Document\Page\Pages\CreatePage; @@ -27,7 +28,6 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Arr; use Illuminate\Support\Str; -use Illuminate\Validation\Rule; /** * Class Page. @@ -101,18 +101,6 @@ public static function getRecordSlug(): string return 'pages'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return PageModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * @@ -141,25 +129,10 @@ public static function form(Form $form): Form ->live(true) ->afterStateUpdated(fn (Set $set, Get $get) => static::setSlug($set, $get)), - TextInput::make(PageModel::ATTRIBUTE_SLUG) + Slug::make(PageModel::ATTRIBUTE_SLUG) ->label(__('filament.fields.page.slug.name')) ->helperText(__('filament.fields.page.slug.help')) - ->required() - ->unique(PageModel::class, PageModel::ATTRIBUTE_SLUG, ignoreRecord: true) - ->maxLength(192) - ->regex('/^[\pL\pM\pN\/_-]+$/u') - ->rules([ - fn ($record) => [ - 'required', - 'max:192', - 'regex:/^[\pL\pM\pN\/_-]+$/u', - $record !== null - ? Rule::unique(PageModel::class) - ->ignore($record->getKey(), PageModel::ATTRIBUTE_ID) - ->__toString() - : Rule::unique(PageModel::class)->__toString(), - ] - ]), + ->regex('/^[\pL\pM\pN\/_-]+$/u'), MarkdownEditor::make(PageModel::ATTRIBUTE_BODY) ->label(__('filament.fields.page.body.name')) diff --git a/app/Filament/Resources/List/External/ExternalEntry.php b/app/Filament/Resources/List/External/ExternalEntry.php index 24e667eb3..e60d19d59 100644 --- a/app/Filament/Resources/List/External/ExternalEntry.php +++ b/app/Filament/Resources/List/External/ExternalEntry.php @@ -102,18 +102,6 @@ public static function getRecordSlug(): string return 'external-entries'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return ExternalEntryModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/List/ExternalProfile.php b/app/Filament/Resources/List/ExternalProfile.php index 9340e35f7..635d5940a 100644 --- a/app/Filament/Resources/List/ExternalProfile.php +++ b/app/Filament/Resources/List/ExternalProfile.php @@ -99,18 +99,6 @@ public static function getRecordSlug(): string return 'external-profiles'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return ExternalProfileModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/List/Playlist.php b/app/Filament/Resources/List/Playlist.php index daeb475d3..9808d6e96 100644 --- a/app/Filament/Resources/List/Playlist.php +++ b/app/Filament/Resources/List/Playlist.php @@ -103,18 +103,6 @@ public static function getRecordSlug(): string return 'playlists'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return PlaylistModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/List/Playlist/Track.php b/app/Filament/Resources/List/Playlist/Track.php index 84e2b039a..85230f4ec 100644 --- a/app/Filament/Resources/List/Playlist/Track.php +++ b/app/Filament/Resources/List/Playlist/Track.php @@ -103,18 +103,6 @@ public static function getRecordSlug(): string return 'tracks'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return TrackModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Wiki/Anime.php b/app/Filament/Resources/Wiki/Anime.php index 4d4fecb6e..301c2a929 100644 --- a/app/Filament/Resources/Wiki/Anime.php +++ b/app/Filament/Resources/Wiki/Anime.php @@ -13,6 +13,7 @@ use App\Filament\Actions\Models\Wiki\Anime\BackfillAnimeAction; use App\Filament\Components\Columns\TextColumn; use App\Filament\Components\Fields\Select; +use App\Filament\Components\Fields\Slug; use App\Filament\Components\Filters\NumberFilter; use App\Filament\Components\Infolist\TextEntry; use App\Filament\Resources\BaseResource; @@ -40,7 +41,6 @@ use Filament\Tables\Filters\SelectFilter; use Filament\Tables\Table; use Illuminate\Support\Str; -use Illuminate\Validation\Rule; use Illuminate\Validation\Rules\Enum; /** @@ -139,18 +139,6 @@ public static function getRecordSlug(): string return 'anime'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return AnimeModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * @@ -172,23 +160,9 @@ public static function form(Form $form): Form ->live(true) ->afterStateUpdated(fn (Set $set, ?string $state) => $set(AnimeModel::ATTRIBUTE_SLUG, Str::slug($state, '_'))), - TextInput::make(AnimeModel::ATTRIBUTE_SLUG) + Slug::make(AnimeModel::ATTRIBUTE_SLUG) ->label(__('filament.fields.anime.slug.name')) - ->helperText(__('filament.fields.anime.slug.help')) - ->required() - ->unique(AnimeModel::class, AnimeModel::ATTRIBUTE_SLUG, ignoreRecord: true) - ->rules([ - fn ($record) => [ - 'required', - 'max:192', - 'alpha_dash', - $record !== null - ? Rule::unique(AnimeModel::class) - ->ignore($record->getKey(), AnimeModel::ATTRIBUTE_ID) - ->__toString() - : Rule::unique(AnimeModel::class)->__toString(), - ] - ]), + ->helperText(__('filament.fields.anime.slug.help')), TextInput::make(AnimeModel::ATTRIBUTE_YEAR) ->label(__('filament.fields.anime.year.name')) diff --git a/app/Filament/Resources/Wiki/Anime/Synonym.php b/app/Filament/Resources/Wiki/Anime/Synonym.php index 8f8831f9b..a6af3d125 100644 --- a/app/Filament/Resources/Wiki/Anime/Synonym.php +++ b/app/Filament/Resources/Wiki/Anime/Synonym.php @@ -99,18 +99,6 @@ public static function getRecordSlug(): string return 'anime-synonyms'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return SynonymModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Wiki/Anime/Theme.php b/app/Filament/Resources/Wiki/Anime/Theme.php index a7b163002..a79a123cc 100644 --- a/app/Filament/Resources/Wiki/Anime/Theme.php +++ b/app/Filament/Resources/Wiki/Anime/Theme.php @@ -143,18 +143,6 @@ public static function getRecordSlug(): string return 'anime-themes'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return ThemeModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Wiki/Anime/Theme/Entry.php b/app/Filament/Resources/Wiki/Anime/Theme/Entry.php index 7416340c8..dd9f67bbc 100644 --- a/app/Filament/Resources/Wiki/Anime/Theme/Entry.php +++ b/app/Filament/Resources/Wiki/Anime/Theme/Entry.php @@ -134,18 +134,6 @@ public static function getRecordSlug(): string return 'anime-theme-entries'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return EntryModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Wiki/Artist.php b/app/Filament/Resources/Wiki/Artist.php index 8f02c8988..9a9b78eb8 100644 --- a/app/Filament/Resources/Wiki/Artist.php +++ b/app/Filament/Resources/Wiki/Artist.php @@ -7,6 +7,7 @@ use App\Filament\Actions\Models\Wiki\Artist\AttachArtistImageAction; use App\Filament\Actions\Models\Wiki\Artist\AttachArtistResourceAction; use App\Filament\Components\Columns\TextColumn; +use App\Filament\Components\Fields\Slug; use App\Filament\Components\Infolist\TextEntry; use App\Filament\Resources\BaseResource; use App\Filament\Resources\Wiki\Artist\Pages\CreateArtist; @@ -32,7 +33,6 @@ use Filament\Tables\Actions\ActionGroup; use Filament\Tables\Table; use Illuminate\Support\Str; -use Illuminate\Validation\Rule; /** * Class Artist. @@ -130,18 +130,6 @@ public static function getRecordTitleAttribute(): string return ArtistModel::ATTRIBUTE_NAME; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return ArtistModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * @@ -163,24 +151,9 @@ public static function form(Form $form): Form ->live(true) ->afterStateUpdated(fn (Set $set, ?string $state) => $set(ArtistModel::ATTRIBUTE_SLUG, Str::slug($state, '_'))), - TextInput::make(ArtistModel::ATTRIBUTE_SLUG) + Slug::make(ArtistModel::ATTRIBUTE_SLUG) ->label(__('filament.fields.artist.slug.name')) - ->helperText(__('filament.fields.artist.slug.help')) - ->required() - ->maxLength(192) - ->unique(ArtistModel::class, ArtistModel::ATTRIBUTE_SLUG, ignoreRecord: true) - ->rules([ - fn ($record) => [ - 'required', - 'max:192', - 'alpha_dash', - $record instanceof ArtistModel - ? Rule::unique(ArtistModel::class) - ->ignore($record->getKey(), ArtistModel::ATTRIBUTE_ID) - ->__toString() - : Rule::unique(ArtistModel::class)->__toString(), - ] - ]), + ->helperText(__('filament.fields.artist.slug.help')), TextInput::make(ArtistResource::ATTRIBUTE_AS) ->label(__('filament.fields.artist.resources.as.name')) diff --git a/app/Filament/Resources/Wiki/Audio.php b/app/Filament/Resources/Wiki/Audio.php index e526c477f..1b4c478d9 100644 --- a/app/Filament/Resources/Wiki/Audio.php +++ b/app/Filament/Resources/Wiki/Audio.php @@ -99,18 +99,6 @@ public static function getRecordSlug(): string return 'audios'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return AudioModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Wiki/ExternalResource.php b/app/Filament/Resources/Wiki/ExternalResource.php index 78e0f842a..b27c54c05 100644 --- a/app/Filament/Resources/Wiki/ExternalResource.php +++ b/app/Filament/Resources/Wiki/ExternalResource.php @@ -103,18 +103,6 @@ public static function getRecordSlug(): string return 'external-resources'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return ExternalResourceModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Wiki/Group.php b/app/Filament/Resources/Wiki/Group.php index e1cd09823..d3bf19df9 100644 --- a/app/Filament/Resources/Wiki/Group.php +++ b/app/Filament/Resources/Wiki/Group.php @@ -105,18 +105,6 @@ public static function getRecordTitleAttribute(): string return GroupModel::ATTRIBUTE_NAME; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return GroupModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Wiki/Image.php b/app/Filament/Resources/Wiki/Image.php index 763321df2..ed617c794 100644 --- a/app/Filament/Resources/Wiki/Image.php +++ b/app/Filament/Resources/Wiki/Image.php @@ -101,18 +101,6 @@ public static function getRecordSlug(): string return 'images'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return ImageModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Wiki/Series.php b/app/Filament/Resources/Wiki/Series.php index cce69ab9e..f909c0017 100644 --- a/app/Filament/Resources/Wiki/Series.php +++ b/app/Filament/Resources/Wiki/Series.php @@ -5,6 +5,7 @@ namespace App\Filament\Resources\Wiki; use App\Filament\Components\Columns\TextColumn; +use App\Filament\Components\Fields\Slug; use App\Filament\Components\Infolist\TextEntry; use App\Filament\Resources\BaseResource; use App\Filament\Resources\Wiki\Series\Pages\CreateSeries; @@ -21,7 +22,6 @@ use Filament\Resources\RelationManagers\RelationGroup; use Filament\Tables\Table; use Illuminate\Support\Str; -use Illuminate\Validation\Rule; /** * Class Series. @@ -119,18 +119,6 @@ public static function getRecordTitleAttribute(): string return SeriesModel::ATTRIBUTE_NAME; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return SeriesModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * @@ -152,24 +140,9 @@ public static function form(Form $form): Form ->live(true) ->afterStateUpdated(fn (Set $set, ?string $state) => $set(SeriesModel::ATTRIBUTE_SLUG, Str::slug($state, '_'))), - TextInput::make(SeriesModel::ATTRIBUTE_SLUG) + Slug::make(SeriesModel::ATTRIBUTE_SLUG) ->label(__('filament.fields.series.slug.name')) - ->helperText(__('filament.fields.series.slug.help')) - ->required() - ->maxLength(192) - ->unique(SeriesModel::class, SeriesModel::ATTRIBUTE_SLUG, ignoreRecord: true) - ->rules([ - fn ($record) => [ - 'required', - 'max:192', - 'alpha_dash', - $record !== null - ? Rule::unique(SeriesModel::class) - ->ignore($record->getKey(), SeriesModel::ATTRIBUTE_ID) - ->__toString() - : Rule::unique(SeriesModel::class)->__toString(), - ] - ]), + ->helperText(__('filament.fields.series.slug.help')), ]) ->columns(1); } diff --git a/app/Filament/Resources/Wiki/Song.php b/app/Filament/Resources/Wiki/Song.php index cc9808b29..9e922da69 100644 --- a/app/Filament/Resources/Wiki/Song.php +++ b/app/Filament/Resources/Wiki/Song.php @@ -124,18 +124,6 @@ public static function getRecordTitleAttribute(): string return SongModel::ATTRIBUTE_TITLE; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return SongModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * @@ -151,9 +139,9 @@ public static function form(Form $form): Form TextInput::make(SongModel::ATTRIBUTE_TITLE) ->label(__('filament.fields.song.title.name')) ->helperText(__('filament.fields.song.title.help')) - ->nullable() + ->required() ->maxLength(192) - ->rules(['nullable', 'max:192']), + ->rules(['required', 'max:192']), TextInput::make(SongResource::ATTRIBUTE_AS) ->label(__('filament.fields.song.resources.as.name')) diff --git a/app/Filament/Resources/Wiki/Studio.php b/app/Filament/Resources/Wiki/Studio.php index 81ee92afa..d03f97ab0 100644 --- a/app/Filament/Resources/Wiki/Studio.php +++ b/app/Filament/Resources/Wiki/Studio.php @@ -8,6 +8,7 @@ use App\Filament\Actions\Models\Wiki\Studio\AttachStudioResourceAction; use App\Filament\Actions\Models\Wiki\Studio\BackfillStudioAction; use App\Filament\Components\Columns\TextColumn; +use App\Filament\Components\Fields\Slug; use App\Filament\Components\Infolist\TextEntry; use App\Filament\Resources\BaseResource; use App\Filament\Resources\Wiki\ExternalResource\RelationManagers\StudioResourceRelationManager; @@ -29,7 +30,6 @@ use Filament\Tables\Actions\ActionGroup; use Filament\Tables\Table; use Illuminate\Support\Str; -use Illuminate\Validation\Rule; /** * Class Studio. @@ -103,18 +103,6 @@ public static function getRecordSlug(): string return 'studios'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return StudioModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * @@ -136,24 +124,9 @@ public static function form(Form $form): Form ->live(true) ->afterStateUpdated(fn (Set $set, ?string $state) => $set(StudioModel::ATTRIBUTE_SLUG, Str::slug($state, '_'))), - TextInput::make(StudioModel::ATTRIBUTE_SLUG) + Slug::make(StudioModel::ATTRIBUTE_SLUG) ->label(__('filament.fields.studio.slug.name')) - ->helperText(__('filament.fields.studio.slug.help')) - ->required() - ->maxLength(192) - ->unique(StudioModel::class, StudioModel::ATTRIBUTE_SLUG, ignoreRecord: true) - ->rules([ - fn ($record) => [ - 'required', - 'max:192', - 'alpha_dash', - $record !== null - ? Rule::unique(StudioModel::class) - ->ignore($record->getKey(), StudioModel::ATTRIBUTE_ID) - ->__toString() - : Rule::unique(StudioModel::class)->__toString(), - ] - ]), + ->helperText(__('filament.fields.studio.slug.help')), TextInput::make(StudioResource::ATTRIBUTE_AS) ->label(__('filament.fields.studio.resources.as.name')) diff --git a/app/Filament/Resources/Wiki/Video.php b/app/Filament/Resources/Wiki/Video.php index 069a58549..d526c97e5 100644 --- a/app/Filament/Resources/Wiki/Video.php +++ b/app/Filament/Resources/Wiki/Video.php @@ -111,18 +111,6 @@ public static function getRecordSlug(): string return 'videos'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return VideoModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/Resources/Wiki/Video/Script.php b/app/Filament/Resources/Wiki/Video/Script.php index c4ca497f3..09c02764b 100644 --- a/app/Filament/Resources/Wiki/Video/Script.php +++ b/app/Filament/Resources/Wiki/Video/Script.php @@ -95,18 +95,6 @@ public static function getRecordSlug(): string return 'video-scripts'; } - /** - * Get the route key for the resource. - * - * @return string - * - * @noinspection PhpMissingParentCallCommonInspection - */ - public static function getRecordRouteKeyName(): string - { - return ScriptModel::ATTRIBUTE_ID; - } - /** * The form to the actions. * diff --git a/app/Filament/TableActions/BaseTableAction.php b/app/Filament/TableActions/BaseTableAction.php index b6ad0020e..dda381f15 100644 --- a/app/Filament/TableActions/BaseTableAction.php +++ b/app/Filament/TableActions/BaseTableAction.php @@ -32,7 +32,7 @@ protected function setUp(): void $this->requiresConfirmation(); - $this->afterFormValidated(function ($livewire, BaseTableAction $action) { + $this->before(function ($livewire, BaseTableAction $action) { if ($livewire instanceof BaseRelationManager) { $this->createActionLog($action, $livewire->getOwnerRecord()); $livewire->dispatch('updateAllRelationManager');