feat: Implement various action classes for Filament, including BackAction, GoToDateAction, and cheerful actions for create, edit, delete, force delete, and restore functionalities.
This commit is contained in:
parent
4b35d8ec48
commit
923b722ed3
22
app/Filament/Actions/BackAction.php
Normal file
22
app/Filament/Actions/BackAction.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
|
||||
class BackAction extends Action
|
||||
{
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
return 'back';
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->label('Kembali')
|
||||
->color('secondary')
|
||||
->outlined();
|
||||
}
|
||||
}
|
||||
18
app/Filament/Actions/Cheerful/CreateAction.php
Normal file
18
app/Filament/Actions/Cheerful/CreateAction.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Actions\Cheerful;
|
||||
|
||||
use App\Filament\Support\SystemNotification;
|
||||
use Filament\Actions\CreateAction as ActionsCreateAction;
|
||||
|
||||
class CreateAction extends ActionsCreateAction
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->successNotification(
|
||||
SystemNotification::create()
|
||||
);
|
||||
}
|
||||
}
|
||||
18
app/Filament/Actions/Cheerful/DeleteAction.php
Normal file
18
app/Filament/Actions/Cheerful/DeleteAction.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Actions\Cheerful;
|
||||
|
||||
use App\Filament\Support\SystemNotification;
|
||||
use Filament\Actions\DeleteAction as ActionsDeleteAction;
|
||||
|
||||
class DeleteAction extends ActionsDeleteAction
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->successNotification(
|
||||
SystemNotification::delete()
|
||||
);
|
||||
}
|
||||
}
|
||||
18
app/Filament/Actions/Cheerful/EditAction.php
Normal file
18
app/Filament/Actions/Cheerful/EditAction.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Actions\Cheerful;
|
||||
|
||||
use App\Filament\Support\SystemNotification;
|
||||
use Filament\Actions\EditAction as ActionsEditAction;
|
||||
|
||||
class EditAction extends ActionsEditAction
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->successNotification(
|
||||
SystemNotification::update()
|
||||
);
|
||||
}
|
||||
}
|
||||
18
app/Filament/Actions/Cheerful/ForceDeleteAction.php
Normal file
18
app/Filament/Actions/Cheerful/ForceDeleteAction.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Actions\Cheerful;
|
||||
|
||||
use App\Filament\Support\SystemNotification;
|
||||
use Filament\Actions\ForceDeleteAction as ActionsForceDeleteAction;
|
||||
|
||||
class ForceDeleteAction extends ActionsForceDeleteAction
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->successNotification(
|
||||
SystemNotification::forceDelete()
|
||||
);
|
||||
}
|
||||
}
|
||||
18
app/Filament/Actions/Cheerful/RestoreAction.php
Normal file
18
app/Filament/Actions/Cheerful/RestoreAction.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Actions\Cheerful;
|
||||
|
||||
use App\Filament\Support\SystemNotification;
|
||||
use Filament\Actions\RestoreAction as ActionsRestoreAction;
|
||||
|
||||
class RestoreAction extends ActionsRestoreAction
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->successNotification(
|
||||
SystemNotification::restore()
|
||||
);
|
||||
}
|
||||
}
|
||||
34
app/Filament/Actions/DefaultBulkActions.php
Normal file
34
app/Filament/Actions/DefaultBulkActions.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Actions;
|
||||
|
||||
use App\Filament\Support\SystemNotification;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\RestoreBulkAction;
|
||||
|
||||
class DefaultBulkActions
|
||||
{
|
||||
public static function make(string $entity): array
|
||||
{
|
||||
return [
|
||||
DeleteBulkAction::make()
|
||||
->modalHeading("Hapus {$entity} yang dipilih")
|
||||
->successNotification(
|
||||
SystemNotification::bulkDelete()
|
||||
),
|
||||
|
||||
ForceDeleteBulkAction::make()
|
||||
->modalHeading("Hapus {$entity} yang dipilih")
|
||||
->successNotification(
|
||||
SystemNotification::bulkForceDelete()
|
||||
),
|
||||
|
||||
RestoreBulkAction::make()
|
||||
->modalHeading("Pulihkan {$entity} yang dipilih")
|
||||
->successNotification(
|
||||
SystemNotification::bulkRestore()
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Filament/Actions/GoToDateAction.php
Normal file
35
app/Filament/Actions/GoToDateAction.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Support\Enums\Width;
|
||||
|
||||
class GoToDateAction extends Action
|
||||
{
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
return 'goToDate';
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->label('Lompat ke Tanggal')
|
||||
->icon('heroicon-o-calendar-days')
|
||||
->schema([
|
||||
DatePicker::make('date')
|
||||
->label('Pilih Tanggal')
|
||||
->placeholder(fn () => now()->addMonth(10)->format('l, d F Y'))
|
||||
->required()
|
||||
->native(false)
|
||||
->displayFormat('l, d F Y'),
|
||||
])
|
||||
->action(function (array $data, $livewire) {
|
||||
$livewire->setOption('date', $data['date']);
|
||||
})
|
||||
->modalWidth(Width::Large);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user