simedkom/app/Filament/Resources/Publication/News/Pages/CreateNews.php
Yoga Pangestu 2c5b057958 feat(news): implement news resource with CRUD functionality
- Created NewsResource for managing news entries.
- Added pages for creating, editing, and listing news.
- Defined NewsForm schema for news entry forms.
- Configured NewsTable for displaying news records with actions.
- Implemented News model with relationships and soft deletes.
- Added factories for generating test data for news and tags.
- Created migrations for news and tags tables.
2025-12-12 09:48:34 +07:00

39 lines
1007 B
PHP

<?php
namespace App\Filament\Resources\Publication\News\Pages;
use App\Filament\Resources\Publication\News\NewsResource;
use Filament\Actions\Action;
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 getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}
protected function getHeaderActions(): array
{
return [
Action::make('back')
->label('Kembali')
->url(fn (): string => route('filament.dashboard.resources.publication.news.index'))
->outlined()
->color('secondary'),
];
}
protected function handleRecordCreation(array $data): Model
{
$data['author_id'] = auth()->id();
return static::getModel()::create($data);
}
}