You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 More refactored 🆙
This commit is contained in:
@@ -92,7 +92,7 @@ class ArticleResource extends Resource
|
||||
->columnSpan('full'),
|
||||
|
||||
Hidden::make('user_id')
|
||||
->default(fn () => auth()->check() ? auth()->user()->id : null),
|
||||
->default(fn () => auth()->id()),
|
||||
]),
|
||||
|
||||
Tab::make(__('filament::resources.tabs.Configurations'))
|
||||
@@ -104,8 +104,8 @@ class ArticleResource extends Resource
|
||||
->offIcon('heroicon-s-x-mark')
|
||||
->default(true)
|
||||
->live()
|
||||
->afterStateUpdated(function (string $operation, $state, $record): void {
|
||||
if ($operation !== 'edit' || is_null($record)) {
|
||||
->afterStateUpdated(function (string $operation, bool $state, ?\App\Models\Articles\WebsiteArticle $record): void {
|
||||
if ($operation !== 'edit' || $record === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -119,12 +119,8 @@ class ArticleResource extends Resource
|
||||
report($e);
|
||||
}
|
||||
})
|
||||
->formatStateUsing(function ($record) {
|
||||
if (is_null($record)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return is_null($record->deleted_at);
|
||||
->formatStateUsing(function (?\App\Models\Articles\WebsiteArticle $record): bool {
|
||||
return $record?->deleted_at === null;
|
||||
}),
|
||||
|
||||
Toggle::make('can_comment')
|
||||
@@ -189,7 +185,7 @@ class ArticleResource extends Resource
|
||||
->label(__('filament::resources.columns.visible'))
|
||||
->onIcon('heroicon-s-check')
|
||||
->toggleable()
|
||||
->state(fn ($record) => is_null($record->deleted_at))
|
||||
->state(fn (\App\Models\Articles\WebsiteArticle $record) => is_null($record->deleted_at))
|
||||
->disabled(),
|
||||
|
||||
ToggleColumn::make('allow_comments')
|
||||
@@ -228,6 +224,6 @@ class ArticleResource extends Resource
|
||||
|
||||
public static function getGlobalSearchEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getGlobalSearchEloquentQuery()->withTrashed();
|
||||
return \App\Models\Articles\WebsiteArticle::query()->withTrashed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class CreateArticle extends CreateRecord
|
||||
/** @var null|WebsiteArticle $articleCreated */
|
||||
$articleCreated = $this->getRecord();
|
||||
|
||||
if (! $articleCreated || ! $articleCreated->visible) {
|
||||
if (! $articleCreated || ! (bool) ($articleCreated->getAttribute('is_visible') ?? false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Atom\Articles\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Articles\ArticleResource;
|
||||
use App\Models\Articles\WebsiteArticle;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
@@ -19,9 +20,9 @@ class ViewArticle extends ViewRecord
|
||||
Action::make('Send Notification')
|
||||
->label(__('Send notifications'))
|
||||
->color('gray')
|
||||
->visible(fn (Model $record) => $record->user_id === Auth::id())
|
||||
->visible(fn (WebsiteArticle $record) => $record->user_id === Auth::id())
|
||||
->requiresConfirmation()
|
||||
->action(function (Model $record): void {
|
||||
->action(function (WebsiteArticle $record): void {
|
||||
$record->createFollowersNotification();
|
||||
}),
|
||||
|
||||
|
||||
+7
-2
@@ -13,6 +13,7 @@ use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class TagsRelationManager extends RelationManager
|
||||
{
|
||||
@@ -38,13 +39,17 @@ class TagsRelationManager extends RelationManager
|
||||
{
|
||||
return $table
|
||||
->columns(TagResource::getTable())
|
||||
->modifyQueryUsing(fn ($query) => $query->latest())
|
||||
->modifyQueryUsing(fn (Builder $query) => $query->latest())
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make()
|
||||
->schema(TagResource::getForm()),
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]),
|
||||
|
||||
AttachAction::make()->preloadRecordSelect(),
|
||||
])
|
||||
|
||||
@@ -82,6 +82,9 @@ class CmsSettingResource extends Resource
|
||||
->searchable()
|
||||
->tooltip(function (TextColumn $column): ?string {
|
||||
$state = $column->getState();
|
||||
if (! is_string($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (strlen($state) <= $column->getCharacterLimit()) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user