46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Publication\News\Pages;
|
|
|
|
use App\Filament\Resources\Publication\News\NewsResource;
|
|
use App\Filament\Support\CheerfulNotification;
|
|
use Filament\Actions\Action;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\CreateRecord;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CreateNews extends CreateRecord
|
|
{
|
|
protected static string $resource = NewsResource::class;
|
|
|
|
protected static ?string $title = 'Tambah Berita';
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('back')
|
|
->label('Kembali')
|
|
->url(ListNews::getUrl())
|
|
->outlined()
|
|
->color('secondary'),
|
|
];
|
|
}
|
|
|
|
protected function getCreatedNotification(): ?Notification
|
|
{
|
|
return CheerfulNotification::create();
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|