simedkom/app/Filament/Resources/Publication/News/NewsResource.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

70 lines
1.9 KiB
PHP

<?php
namespace App\Filament\Resources\Publication\News;
use App\Filament\Resources\Publication\News\Pages\CreateNews;
use App\Filament\Resources\Publication\News\Pages\EditNews;
use App\Filament\Resources\Publication\News\Pages\ListNews;
use App\Filament\Resources\Publication\News\Schemas\NewsForm;
use App\Filament\Resources\Publication\News\Tables\NewsTable;
use App\Models\News;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use UnitEnum;
class NewsResource extends Resource
{
protected static ?string $model = News::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::Newspaper;
protected static ?string $navigationLabel = 'Berita';
protected static string|UnitEnum|null $navigationGroup = 'Publikasi';
protected static ?string $slug = 'publication/news';
protected static ?string $recordTitleAttribute = 'title';
protected static ?int $navigationSort = 1;
public static function form(Schema $schema): Schema
{
return NewsForm::configure($schema);
}
public static function table(Table $table): Table
{
return NewsTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListNews::route('/'),
'create' => CreateNews::route('/create'),
'edit' => EditNews::route('/{record}/edit'),
];
}
public static function getRecordRouteBindingEloquentQuery(): Builder
{
return parent::getRecordRouteBindingEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}