feat: tambah Filament 5 resources dengan schemas dan tables
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CashCategories;
|
||||
|
||||
use App\Filament\Resources\CashCategories\Pages\CreateCashCategory;
|
||||
use App\Filament\Resources\CashCategories\Pages\EditCashCategory;
|
||||
use App\Filament\Resources\CashCategories\Pages\ListCashCategories;
|
||||
use App\Filament\Resources\CashCategories\Schemas\CashCategoryForm;
|
||||
use App\Filament\Resources\CashCategories\Tables\CashCategoriesTable;
|
||||
use App\Models\CashCategory;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CashCategoryResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CashCategory::class;
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-tag';
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Keuangan';
|
||||
protected static ?string $modelLabel = 'Kategori Kas';
|
||||
|
||||
public static function form(Schema $form): Schema
|
||||
{
|
||||
return CashCategoryForm::configure($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return CashCategoriesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListCashCategories::route('/'),
|
||||
'create' => CreateCashCategory::route('/create'),
|
||||
'edit' => EditCashCategory::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CashCategories\Pages;
|
||||
|
||||
use App\Filament\Resources\CashCategories\CashCategoryResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCashCategory extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CashCategoryResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CashCategories\Pages;
|
||||
|
||||
use App\Filament\Resources\CashCategories\CashCategoryResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCashCategory extends EditRecord
|
||||
{
|
||||
protected static string $resource = CashCategoryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CashCategories\Pages;
|
||||
|
||||
use App\Filament\Resources\CashCategories\CashCategoryResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCashCategories extends ListRecords
|
||||
{
|
||||
protected static string $resource = CashCategoryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CashCategories\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class CashCategoryForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
TextInput::make('name')->label('Nama')->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CashCategories\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CashCategoriesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')->label('Nama')->searchable(),
|
||||
TextColumn::make('records_count')->counts('records')->label('Transaksi'),
|
||||
])
|
||||
->recordActions([EditAction::make()])
|
||||
->toolbarActions([BulkActionGroup::make([DeleteBulkAction::make()])]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user