feat: Organize Filament resources with navigation groups, update modal width enum usage, and add clean code documentation.
This commit is contained in:
parent
2603d90271
commit
89f0d511e4
92
README_CLEAN_CODE.md
Normal file
92
README_CLEAN_CODE.md
Normal file
@ -0,0 +1,92 @@
|
||||
# Clean Code Guidelines for Filament Resources
|
||||
|
||||
This document outlines the coding standards and structure for Filament Resources in this project.
|
||||
|
||||
## 1. Class Properties
|
||||
|
||||
Properties within the Resource class should be ordered alphabetically.
|
||||
|
||||
**Example:**
|
||||
```php
|
||||
protected static ?string $model = User::class;
|
||||
protected static ?string $navigationGroup = 'Master';
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::UserGroup;
|
||||
protected static ?string $navigationLabel = 'Pengguna';
|
||||
protected static ?int $navigationSort = 7;
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
protected static ?string $slug = 'master/users';
|
||||
```
|
||||
|
||||
## 2. Form Structure
|
||||
|
||||
Form components should be structured with method calls in the following order:
|
||||
|
||||
1. **Basic**: `make`, `label`, `placeholder`
|
||||
2. **HTML Attributes**: `autocomplete`, `autofocus`, etc.
|
||||
3. **Validation**: `required`, `maxLength`, `email`, `unique`, `regex`, etc.
|
||||
4. **Filament/Logic**: `relationship`, `live`, `afterStateUpdated`, etc.
|
||||
|
||||
**Formatting:**
|
||||
- Use a blank line between each component definition.
|
||||
|
||||
**Example:**
|
||||
```php
|
||||
TextInput::make('name')
|
||||
->label('Nama')
|
||||
->placeholder('John Doe')
|
||||
->autocomplete(false)
|
||||
->autofocus()
|
||||
->required()
|
||||
->maxLength(100),
|
||||
|
||||
TextInput::make('email')
|
||||
->label('Alamat Surel')
|
||||
->placeholder('email@example.com')
|
||||
->autocomplete(false)
|
||||
->required()
|
||||
->email(),
|
||||
```
|
||||
|
||||
## 3. Table Structure
|
||||
|
||||
### Columns
|
||||
Column definitions should be structured in the following order:
|
||||
|
||||
1. **Basic**: `make`, `label`
|
||||
2. **Search & Sort**: `searchable`, `sortable` (These should be present for most fields)
|
||||
3. **State & Attributes**: `getStateUsing`, `updateStateUsing`, `badge`, `icon`
|
||||
4. **Formatting**: `dateTime`, `money`, etc.
|
||||
|
||||
**Formatting:**
|
||||
- Use a blank line between each column definition.
|
||||
|
||||
**Example:**
|
||||
```php
|
||||
TextColumn::make('name')
|
||||
->label('Nama')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
ToggleColumn::make('is_active')
|
||||
->label('Status')
|
||||
->sortable()
|
||||
->updateStateUsing(...),
|
||||
```
|
||||
|
||||
### Table Method Order
|
||||
The methods chained to the `$table` object should follow this order:
|
||||
|
||||
1. `columns([\ ... ])`
|
||||
2. `filters([\ ... ])`
|
||||
3. `recordActions([\ ... ])` (or `actions`)
|
||||
4. `toolbarActions([\ ... ])` (or `headerActions`)
|
||||
5. `emptyStateIcon(...)`
|
||||
6. `emptyStateDescription(...)`
|
||||
7. `defaultSort(...)`
|
||||
8. `deferFilters(...)`
|
||||
9. Other configuration methods.
|
||||
|
||||
## 4. General Formatting
|
||||
|
||||
- Ensure consistent indentation.
|
||||
- Always use a blank line to separate distinct logical blocks or component definitions to improve readability.
|
||||
@ -11,7 +11,6 @@ public static function make(): array
|
||||
return [
|
||||
TextColumn::make('created_at')
|
||||
->label('Dibuat')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true)
|
||||
->dateTime('l, d F Y H:i:s')
|
||||
@ -19,7 +18,6 @@ public static function make(): array
|
||||
|
||||
TextColumn::make('updated_at')
|
||||
->label('Diperbarui')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true)
|
||||
->dateTime('l, d F Y H:i:s')
|
||||
@ -27,7 +25,6 @@ public static function make(): array
|
||||
|
||||
TextColumn::make('deleted_at')
|
||||
->label('Dihapus')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true)
|
||||
->dateTime('l, d F Y H:i:s')
|
||||
|
||||
@ -30,17 +30,17 @@ class CooperationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Cooperation::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Manage';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::HandRaised;
|
||||
|
||||
protected static ?string $navigationLabel = 'Kerja Sama';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Manage';
|
||||
|
||||
protected static ?string $slug = 'manage/cooperations';
|
||||
protected static ?int $navigationSort = 20;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'title';
|
||||
|
||||
protected static ?int $navigationSort = 20;
|
||||
protected static ?string $slug = 'manage/cooperations';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -72,9 +72,9 @@ public static function infolist(Schema $schema): Schema
|
||||
Section::make('Informasi Kerja Sama')
|
||||
->headerActions([
|
||||
Action::make('status')
|
||||
->label(fn ($record) => $record->status->getLabel())
|
||||
->label(fn($record) => $record->status->getLabel())
|
||||
->badge()
|
||||
->color(fn ($record) => $record->status->getColor())
|
||||
->color(fn($record) => $record->status->getColor())
|
||||
->disabled(),
|
||||
])
|
||||
->schema([
|
||||
@ -117,7 +117,7 @@ public static function infolist(Schema $schema): Schema
|
||||
->placeholder('Belum dibayar'),
|
||||
]),
|
||||
])
|
||||
->visible(fn ($record) => $record->payment_amount || $record->payment_date),
|
||||
->visible(fn($record) => $record->payment_amount || $record->payment_date),
|
||||
|
||||
TextEntry::make('description')
|
||||
->label('Deskripsi')
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
use Filament\Infolists\Infolist;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
@ -41,7 +42,7 @@ public function table(Table $table): Table
|
||||
|
||||
TextColumn::make('e_catalog')
|
||||
->label('E-Catalog')
|
||||
->url(fn ($record) => $record->e_catalog)
|
||||
->url(fn($record) => $record->e_catalog)
|
||||
->openUrlInNewTab()
|
||||
->color('primary'),
|
||||
|
||||
@ -70,6 +71,7 @@ public function table(Table $table): Table
|
||||
->headerActions([])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
|
||||
Action::make('accept')
|
||||
->label('Terima')
|
||||
->icon(Heroicon::OutlinedCheck)
|
||||
@ -86,7 +88,8 @@ public function table(Table $table): Table
|
||||
->success()
|
||||
->send();
|
||||
})
|
||||
->visible(fn (CooperationProposal $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING),
|
||||
->visible(fn(CooperationProposal $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING),
|
||||
|
||||
Action::make('reject')
|
||||
->label('Tolak')
|
||||
->icon(Heroicon::XMark)
|
||||
@ -111,8 +114,8 @@ public function table(Table $table): Table
|
||||
->warning()
|
||||
->send();
|
||||
})
|
||||
->visible(fn (CooperationProposal $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING)
|
||||
->modalWidth('lg'),
|
||||
->visible(fn(CooperationProposal $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING)
|
||||
->modalWidth(Width::Large),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
@ -36,22 +37,26 @@ public function form(Schema $schema): Schema
|
||||
->placeholder('Dirgahayu Purwakarta')
|
||||
->required()
|
||||
->maxLength(200),
|
||||
|
||||
DatePicker::make('publication_date')
|
||||
->label('Tanggal Publikasi')
|
||||
->placeholder(fn () => now()->format('l, d F Y'))
|
||||
->placeholder(fn() => now()->format('l, d F Y'))
|
||||
->native(false)
|
||||
->displayFormat('l, d F Y')
|
||||
->required(),
|
||||
|
||||
TextInput::make('link')
|
||||
->label('Tautan')
|
||||
->placeholder('https://example.com')
|
||||
->maxLength(50)
|
||||
->url()
|
||||
->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Deskripsi')
|
||||
->placeholder('....')
|
||||
->required(),
|
||||
|
||||
SpatieMediaLibraryFileUpload::make('image')
|
||||
->label('Gambar')
|
||||
->disk(config('filesystems.default'))
|
||||
@ -72,17 +77,21 @@ public function table(Table $table): Table
|
||||
TextColumn::make('title')
|
||||
->label('Judul')
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('publication_date')
|
||||
->label('Tanggal Publikasi')
|
||||
->date('l, d F Y'),
|
||||
|
||||
TextColumn::make('link')
|
||||
->label('Link')
|
||||
->limit(30)
|
||||
->url(fn ($record) => $record->link)
|
||||
->url(fn($record) => $record->link)
|
||||
->openUrlInNewTab(),
|
||||
|
||||
TextColumn::make('status')
|
||||
->label('Status')
|
||||
->badge(),
|
||||
|
||||
TextColumn::make('rejectionReasons.reason')
|
||||
->label('Alasan Penolakan')
|
||||
->searchable(),
|
||||
@ -104,7 +113,8 @@ public function table(Table $table): Table
|
||||
->success()
|
||||
->send();
|
||||
})
|
||||
->visible(fn (Report $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING),
|
||||
->visible(fn(Report $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING),
|
||||
|
||||
Action::make('reject')
|
||||
->label('Tolak')
|
||||
->icon(Heroicon::XMark)
|
||||
@ -128,8 +138,8 @@ public function table(Table $table): Table
|
||||
->warning()
|
||||
->send();
|
||||
})
|
||||
->visible(fn (Report $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING)
|
||||
->modalWidth('lg'),
|
||||
->visible(fn(Report $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING)
|
||||
->modalWidth(Width::Large),
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make()
|
||||
|
||||
@ -90,11 +90,10 @@ public function table(Table $table): Table
|
||||
|
||||
TextColumn::make('report_amount')
|
||||
->label('Jumlah Laporan'),
|
||||
|
||||
TextColumn::make('report_count')
|
||||
->label('Laporan Diterima')
|
||||
->getStateUsing(function (TaskAssignment $record) {
|
||||
return $record->reports()->count().' / '.($record->report_amount * $record->partnerMedia()->count());
|
||||
return $record->reports()->count() . ' / ' . ($record->report_amount * $record->partnerMedia()->count());
|
||||
}),
|
||||
])
|
||||
->filters([
|
||||
@ -103,7 +102,7 @@ public function table(Table $table): Table
|
||||
->headerActions([
|
||||
CreateAction::make()
|
||||
->label('Buat Penugasan')
|
||||
->visible(fn () => $this->canCreateTaskAssignment()),
|
||||
->visible(fn() => $this->canCreateTaskAssignment()),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
@ -34,17 +35,17 @@ class JournalistResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Journalist::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Kelola';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::Identification;
|
||||
|
||||
protected static ?string $navigationLabel = 'Jurnalis';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Kelola';
|
||||
|
||||
protected static ?string $slug = 'manage/journalists';
|
||||
protected static ?int $navigationSort = 11;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 11;
|
||||
protected static ?string $slug = 'manage/journalists';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -103,7 +104,7 @@ public static function form(Schema $schema): Schema
|
||||
->schema(
|
||||
collect($documents)
|
||||
->map(
|
||||
fn ($doc) => Section::make($doc['title'])
|
||||
fn($doc) => Section::make($doc['title'])
|
||||
->schema([
|
||||
TextInput::make($doc['text_name'])
|
||||
->hiddenLabel()
|
||||
@ -161,11 +162,12 @@ public static function table(Table $table): Table
|
||||
...TimestampColumns::make(),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make()->native(false),
|
||||
TrashedFilter::make()
|
||||
->native(false),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()
|
||||
->modalWidth('lg')
|
||||
->modalWidth(Width::Large)
|
||||
->fillForm(function (Journalist $journalist) {
|
||||
$data = [
|
||||
'name' => $journalist->name,
|
||||
@ -237,8 +239,11 @@ public static function table(Table $table): Table
|
||||
|
||||
return $record;
|
||||
}),
|
||||
|
||||
DeleteAction::make(),
|
||||
|
||||
ForceDeleteAction::make(),
|
||||
|
||||
RestoreAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
@ -27,17 +28,17 @@ class PartnerResource extends Resource
|
||||
{
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Kelola';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::BuildingOffice2;
|
||||
|
||||
protected static ?string $navigationLabel = 'Rekanan';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Kelola';
|
||||
|
||||
protected static ?string $slug = 'manage/partners';
|
||||
protected static ?int $navigationSort = 8;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 8;
|
||||
protected static ?string $slug = 'manage/partners';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -58,7 +59,7 @@ public static function table(Table $table): Table
|
||||
->label('Perusahaan')
|
||||
->searchable()
|
||||
->sortable()
|
||||
->description(fn (User $record) => $record->company?->director_name),
|
||||
->description(fn(User $record) => $record->company?->director_name),
|
||||
|
||||
TextColumn::make('company.partnerMedia.name')
|
||||
->label('Media')
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
@ -29,17 +30,17 @@ class ClassificationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Classification::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::BookOpen;
|
||||
|
||||
protected static ?string $navigationLabel = 'Klasifikasi';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static ?string $slug = 'master/classifications';
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
protected static ?string $slug = 'master/classifications';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -68,22 +69,27 @@ public static function table(Table $table): Table
|
||||
|
||||
ToggleColumn::make('is_active')
|
||||
->label('Aktif?')
|
||||
->getStateUsing(fn (Classification $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->sortable()
|
||||
->getStateUsing(fn(Classification $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->updateStateUsing(function (Classification $record, bool $state) {
|
||||
$record->is_active = $state ? IsActive::ACTIVE : IsActive::INACTIVE;
|
||||
$record->save();
|
||||
})
|
||||
->sortable(),
|
||||
}),
|
||||
|
||||
...TimestampColumns::make(),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make()->native(false),
|
||||
TrashedFilter::make()
|
||||
->native(false),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->modalWidth('lg'),
|
||||
EditAction::make()
|
||||
->modalWidth(Width::Large),
|
||||
|
||||
DeleteAction::make(),
|
||||
|
||||
ForceDeleteAction::make(),
|
||||
|
||||
RestoreAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
@ -29,17 +30,17 @@ class DepartmentResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Department::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::BuildingLibrary;
|
||||
|
||||
protected static ?string $navigationLabel = 'OPD';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static ?string $slug = 'master/departments';
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
protected static ?string $slug = 'master/departments';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -79,22 +80,27 @@ public static function table(Table $table): Table
|
||||
|
||||
ToggleColumn::make('is_active')
|
||||
->label('Aktif?')
|
||||
->getStateUsing(fn (Department $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->sortable()
|
||||
->getStateUsing(fn(Department $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->updateStateUsing(function (Department $record, bool $state) {
|
||||
$record->is_active = $state ? IsActive::ACTIVE : IsActive::INACTIVE;
|
||||
$record->save();
|
||||
})
|
||||
->sortable(),
|
||||
}),
|
||||
|
||||
...TimestampColumns::make(),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make()->native(false),
|
||||
TrashedFilter::make()
|
||||
->native(false),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->modalWidth('lg'),
|
||||
EditAction::make()
|
||||
->modalWidth(Width::Large),
|
||||
|
||||
DeleteAction::make(),
|
||||
|
||||
ForceDeleteAction::make(),
|
||||
|
||||
RestoreAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
@ -29,17 +30,17 @@ class LocationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Location::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::MapPin;
|
||||
|
||||
protected static ?string $navigationLabel = 'Lokasi';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static ?string $slug = 'master/locations';
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static ?string $slug = 'master/locations';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -68,22 +69,27 @@ public static function table(Table $table): Table
|
||||
|
||||
ToggleColumn::make('is_active')
|
||||
->label('Aktif?')
|
||||
->getStateUsing(fn (Location $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->sortable()
|
||||
->getStateUsing(fn(Location $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->updateStateUsing(function (Location $record, bool $state) {
|
||||
$record->is_active = $state ? IsActive::ACTIVE : IsActive::INACTIVE;
|
||||
$record->save();
|
||||
})
|
||||
->sortable(),
|
||||
}),
|
||||
|
||||
...TimestampColumns::make(),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make()->native(false),
|
||||
TrashedFilter::make()
|
||||
->native(false),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->modalWidth('lg'),
|
||||
EditAction::make()
|
||||
->modalWidth(Width::Large),
|
||||
|
||||
DeleteAction::make(),
|
||||
|
||||
ForceDeleteAction::make(),
|
||||
|
||||
RestoreAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
@ -31,17 +32,17 @@ class SubClassificationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = SubClassification::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::QueueList;
|
||||
|
||||
protected static ?string $navigationLabel = 'Sub Klasifikasi';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static ?string $slug = 'master/sub-classifications';
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
protected static ?string $slug = 'master/sub-classifications';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -83,22 +84,27 @@ public static function table(Table $table): Table
|
||||
|
||||
ToggleColumn::make('is_active')
|
||||
->label('Aktif?')
|
||||
->getStateUsing(fn (SubClassification $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->sortable()
|
||||
->getStateUsing(fn(SubClassification $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->updateStateUsing(function (SubClassification $record, bool $state) {
|
||||
$record->is_active = $state ? IsActive::ACTIVE : IsActive::INACTIVE;
|
||||
$record->save();
|
||||
})
|
||||
->sortable(),
|
||||
}),
|
||||
|
||||
...TimestampColumns::make(),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make()->native(false),
|
||||
TrashedFilter::make()
|
||||
->native(false),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->modalWidth('lg'),
|
||||
EditAction::make()
|
||||
->modalWidth(Width::Large),
|
||||
|
||||
DeleteAction::make(),
|
||||
|
||||
ForceDeleteAction::make(),
|
||||
|
||||
RestoreAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
@ -31,17 +32,17 @@ class SubLocationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = SubLocation::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::NumberedList;
|
||||
|
||||
protected static ?string $navigationLabel = 'Sub Lokasi';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static ?string $slug = 'master/sub-locations';
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
protected static ?string $slug = 'master/sub-locations';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -83,22 +84,27 @@ public static function table(Table $table): Table
|
||||
|
||||
ToggleColumn::make('is_active')
|
||||
->label('Aktif?')
|
||||
->getStateUsing(fn (SubLocation $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->sortable()
|
||||
->getStateUsing(fn(SubLocation $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->updateStateUsing(function (SubLocation $record, bool $state) {
|
||||
$record->is_active = $state ? IsActive::ACTIVE : IsActive::INACTIVE;
|
||||
$record->save();
|
||||
})
|
||||
->sortable(),
|
||||
}),
|
||||
|
||||
...TimestampColumns::make(),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make()->native(false),
|
||||
TrashedFilter::make()
|
||||
->native(false),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->modalWidth('lg'),
|
||||
EditAction::make()
|
||||
->modalWidth(Width::Large),
|
||||
|
||||
DeleteAction::make(),
|
||||
|
||||
ForceDeleteAction::make(),
|
||||
|
||||
RestoreAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
@ -29,17 +30,17 @@ class ThemeResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Theme::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::PuzzlePiece;
|
||||
|
||||
protected static ?string $navigationLabel = 'Tema';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static ?string $slug = 'master/themes';
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
protected static ?string $slug = 'master/themes';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -68,22 +69,27 @@ public static function table(Table $table): Table
|
||||
|
||||
ToggleColumn::make('is_active')
|
||||
->label('Aktif?')
|
||||
->getStateUsing(fn (Theme $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->sortable()
|
||||
->getStateUsing(fn(Theme $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->updateStateUsing(function (Theme $record, bool $state) {
|
||||
$record->is_active = $state ? IsActive::ACTIVE : IsActive::INACTIVE;
|
||||
$record->save();
|
||||
})
|
||||
->sortable(),
|
||||
}),
|
||||
|
||||
...TimestampColumns::make(),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make()->native(false),
|
||||
TrashedFilter::make()
|
||||
->native(false),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->modalWidth('lg'),
|
||||
EditAction::make()
|
||||
->modalWidth(Width::Large),
|
||||
|
||||
DeleteAction::make(),
|
||||
|
||||
ForceDeleteAction::make(),
|
||||
|
||||
RestoreAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@ -34,17 +34,17 @@ class UserResource extends Resource
|
||||
{
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::UserGroup;
|
||||
|
||||
protected static ?string $navigationLabel = 'Pengguna';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Master';
|
||||
|
||||
protected static ?string $slug = 'master/users';
|
||||
protected static ?int $navigationSort = 7;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 7;
|
||||
protected static ?string $slug = 'master/users';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -64,8 +64,8 @@ public static function form(Schema $schema): Schema
|
||||
->autocomplete(false)
|
||||
->required()
|
||||
->maxLength(254)
|
||||
->unique(ignoreRecord: true)
|
||||
->email(),
|
||||
->email()
|
||||
->unique(ignoreRecord: true),
|
||||
|
||||
TextInput::make('username')
|
||||
->label('Nama Pengguna')
|
||||
@ -79,14 +79,14 @@ public static function form(Schema $schema): Schema
|
||||
|
||||
Select::make('roles')
|
||||
->label('Peran')
|
||||
->relationship('roles', 'name', fn ($query) => $query->whereNotIn('name', [RoleEnum::DEVELOPER, RoleEnum::PERUSAHAAN]))
|
||||
->required()
|
||||
->relationship('roles', 'name', fn($query) => $query->whereNotIn('name', [RoleEnum::DEVELOPER, RoleEnum::PERUSAHAAN]))
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable()
|
||||
->required(),
|
||||
->searchable(),
|
||||
|
||||
Hidden::make('password')
|
||||
->default(fn ($record) => $record ? null : config('auth.password_default')),
|
||||
->default(fn($record) => $record ? null : config('auth.password_default')),
|
||||
])
|
||||
->columns(1);
|
||||
}
|
||||
@ -98,19 +98,23 @@ public static function table(Table $table): Table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label('Nama')
|
||||
->searchable(),
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('email')
|
||||
->label('Alamat Surel')
|
||||
->searchable(),
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('username')
|
||||
->label('Nama Pengguna')
|
||||
->searchable(),
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
ToggleColumn::make('is_active')
|
||||
->label('Status')
|
||||
->getStateUsing(fn (User $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->sortable()
|
||||
->getStateUsing(fn(User $record) => $record->is_active === IsActive::ACTIVE)
|
||||
->updateStateUsing(function (User $record, bool $state) {
|
||||
$record->is_active = $state ? IsActive::ACTIVE : IsActive::INACTIVE;
|
||||
$record->save();
|
||||
@ -124,20 +128,25 @@ public static function table(Table $table): Table
|
||||
|
||||
TextColumn::make('roles.name')
|
||||
->label('Peran')
|
||||
->getStateUsing(fn (User $record) => $record->roles->pluck('name', 'id')->toArray())
|
||||
->searchable()
|
||||
->sortable()
|
||||
->badge()
|
||||
->sortable(),
|
||||
->getStateUsing(fn(User $record) => $record->roles->pluck('name', 'id')->toArray()),
|
||||
|
||||
...TimestampColumns::make(),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make()->native(false),
|
||||
TrashedFilter::make()
|
||||
->native(false),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()
|
||||
->modalWidth(Width::Large),
|
||||
|
||||
DeleteAction::make(),
|
||||
|
||||
ForceDeleteAction::make(),
|
||||
|
||||
RestoreAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@ -21,17 +21,17 @@ class ContentRecapResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ContentRecap::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Monitoring';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::ClipboardDocumentList;
|
||||
|
||||
protected static ?string $navigationLabel = 'Rekap Konten';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Monitoring';
|
||||
|
||||
protected static ?string $slug = 'monitoring/content-recaps';
|
||||
protected static ?int $navigationSort = 13;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'title';
|
||||
|
||||
protected static ?int $navigationSort = 13;
|
||||
protected static ?string $slug = 'monitoring/content-recaps';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@ -64,8 +64,11 @@ public static function configure(Table $table): Table
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
|
||||
DeleteAction::make(),
|
||||
|
||||
ForceDeleteAction::make(),
|
||||
|
||||
RestoreAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@ -21,17 +21,17 @@ class IssueManagementResource extends Resource
|
||||
{
|
||||
protected static ?string $model = IssueManagement::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Monitoring';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::ExclamationCircle;
|
||||
|
||||
protected static ?string $navigationLabel = 'Manajemen Isu';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Monitoring';
|
||||
|
||||
protected static ?string $slug = 'monitoring/issue-managements';
|
||||
protected static ?int $navigationSort = 13;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'mediaMonitoring.title';
|
||||
|
||||
protected static ?int $navigationSort = 13;
|
||||
protected static ?string $slug = 'monitoring/issue-managements';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@ -52,11 +52,14 @@ public static function configure(Table $table): Table
|
||||
...TimestampColumns::make(),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make()->native(false),
|
||||
TrashedFilter::make()
|
||||
->native(false),
|
||||
|
||||
SelectFilter::make('issue')
|
||||
->label('Filter Isu')
|
||||
->options(\App\Enums\IssueSentiment::class)
|
||||
->native(false),
|
||||
|
||||
SelectFilter::make('response')
|
||||
->label('Filter Respon')
|
||||
->options(\App\Enums\IssueSentiment::class)
|
||||
@ -64,8 +67,11 @@ public static function configure(Table $table): Table
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
|
||||
DeleteAction::make(),
|
||||
|
||||
RestoreAction::make(),
|
||||
|
||||
ForceDeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@ -21,17 +21,17 @@ class MediaMonitoringResource extends Resource
|
||||
{
|
||||
protected static ?string $model = MediaMonitoring::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Monitoring';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::ClipboardDocumentCheck;
|
||||
|
||||
protected static ?string $navigationLabel = 'Monitoring Media';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Monitoring';
|
||||
|
||||
protected static ?string $slug = 'monitoring/media-monitorings';
|
||||
protected static ?int $navigationSort = 12;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'media_name';
|
||||
|
||||
protected static ?int $navigationSort = 12;
|
||||
protected static ?string $slug = 'monitoring/media-monitorings';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@ -80,7 +80,7 @@ public static function configure(Schema $schema): Schema
|
||||
|
||||
Select::make('themes')
|
||||
->label('Tema')
|
||||
->relationship('themes', 'name', fn ($query) => $query->active())
|
||||
->relationship('themes', 'name', fn($query) => $query->active())
|
||||
->native(false)
|
||||
->multiple()
|
||||
->preload()
|
||||
@ -88,7 +88,7 @@ public static function configure(Schema $schema): Schema
|
||||
|
||||
DatePicker::make('release_date')
|
||||
->label('Tanggal Rilis')
|
||||
->placeholder(fn () => now()->format('Y-m-d'))
|
||||
->placeholder(fn() => now()->format('Y-m-d'))
|
||||
->native(false)
|
||||
->displayFormat('l, d F Y')
|
||||
->required(),
|
||||
|
||||
@ -88,8 +88,11 @@ public static function configure(Table $table): Table
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
|
||||
DeleteAction::make(),
|
||||
|
||||
ForceDeleteAction::make(),
|
||||
|
||||
RestoreAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
Loading…
Reference in New Issue
Block a user