diff --git a/app/Filament/Resources/Publication/News/Pages/CreateNews.php b/app/Filament/Resources/Publication/News/Pages/CreateNews.php index 4e9afc9..90944d0 100644 --- a/app/Filament/Resources/Publication/News/Pages/CreateNews.php +++ b/app/Filament/Resources/Publication/News/Pages/CreateNews.php @@ -7,7 +7,6 @@ use Filament\Actions\Action; use Filament\Notifications\Notification; use Filament\Resources\Pages\CreateRecord; -use Illuminate\Database\Eloquent\Model; class CreateNews extends CreateRecord { @@ -35,11 +34,4 @@ protected function getRedirectUrl(): string { return $this->getResource()::getUrl('index'); } - - protected function handleRecordCreation(array $data): Model - { - $data['author_id'] = auth()->id(); - - return static::getModel()::create($data); - } } diff --git a/app/Filament/Resources/Publication/News/Schemas/NewsForm.php b/app/Filament/Resources/Publication/News/Schemas/NewsForm.php index 2fca9bc..87fdbfe 100644 --- a/app/Filament/Resources/Publication/News/Schemas/NewsForm.php +++ b/app/Filament/Resources/Publication/News/Schemas/NewsForm.php @@ -22,6 +22,9 @@ public static function configure(Schema $schema): Schema { return $schema ->components([ + Hidden::make('author_id') + ->default(auth()->id()), + Section::make([ TextInput::make('title') ->label('Judul') diff --git a/app/Filament/Resources/Publication/News/Tables/NewsTable.php b/app/Filament/Resources/Publication/News/Tables/NewsTable.php index 4f3de34..f9b9a82 100644 --- a/app/Filament/Resources/Publication/News/Tables/NewsTable.php +++ b/app/Filament/Resources/Publication/News/Tables/NewsTable.php @@ -33,13 +33,6 @@ public static function configure(Table $table): Table ->searchable() ->sortable() ->placeholder('Tidak ada'), - - TextColumn::make('view') - ->label('Dilihat') - ->numeric() - ->sortable() - ->alignCenter(), - TextColumn::make('categories.name') ->label('Kategori') ->listWithLineBreaks() @@ -73,6 +66,11 @@ public static function configure(Table $table): Table ->formatStateUsing(fn (NewsStatus $state): string => $state->getLabel()) ->color(fn (NewsStatus $state): string => $state->getColor()), + TextColumn::make('views') + ->label('Dilihat') + ->sortable() + ->alignCenter(), + TextColumn::make('published_at') ->label('Tgl Publish') ->searchable()