feat: Add reusable Filament actions, bulk actions, and timestamp columns with custom cheerful notifications.
This commit is contained in:
parent
7a70ef7d74
commit
78e8de28d7
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\CheerfulNotification;
|
||||||
|
use Filament\Actions\CreateAction as ActionsCreateAction;
|
||||||
|
|
||||||
|
class CreateAction extends ActionsCreateAction
|
||||||
|
{
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->successNotification(
|
||||||
|
CheerfulNotification::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\CheerfulNotification;
|
||||||
|
use Filament\Actions\DeleteAction as ActionsDeleteAction;
|
||||||
|
|
||||||
|
class DeleteAction extends ActionsDeleteAction
|
||||||
|
{
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->successNotification(
|
||||||
|
CheerfulNotification::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\CheerfulNotification;
|
||||||
|
use Filament\Actions\EditAction as ActionsEditAction;
|
||||||
|
|
||||||
|
class EditAction extends ActionsEditAction
|
||||||
|
{
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->successNotification(
|
||||||
|
CheerfulNotification::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\CheerfulNotification;
|
||||||
|
use Filament\Actions\ForceDeleteAction as ActionsForceDeleteAction;
|
||||||
|
|
||||||
|
class ForceDeleteAction extends ActionsForceDeleteAction
|
||||||
|
{
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->successNotification(
|
||||||
|
CheerfulNotification::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\CheerfulNotification;
|
||||||
|
use Filament\Actions\RestoreAction as ActionsRestoreAction;
|
||||||
|
|
||||||
|
class RestoreAction extends ActionsRestoreAction
|
||||||
|
{
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->successNotification(
|
||||||
|
CheerfulNotification::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\CheerfulNotification;
|
||||||
|
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(
|
||||||
|
CheerfulNotification::bulkDelete()
|
||||||
|
),
|
||||||
|
|
||||||
|
ForceDeleteBulkAction::make()
|
||||||
|
->modalHeading("Hapus {$entity} yang dipilih")
|
||||||
|
->successNotification(
|
||||||
|
CheerfulNotification::bulkForceDelete()
|
||||||
|
),
|
||||||
|
|
||||||
|
RestoreBulkAction::make()
|
||||||
|
->modalHeading("Pulihkan {$entity} yang dipilih")
|
||||||
|
->successNotification(
|
||||||
|
CheerfulNotification::bulkRestore()
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
34
app/Filament/Columns/TimestampColumns.php
Normal file
34
app/Filament/Columns/TimestampColumns.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Columns;
|
||||||
|
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
|
||||||
|
class TimestampColumns
|
||||||
|
{
|
||||||
|
public static function make(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->label('Dibuat')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true)
|
||||||
|
->dateTime('l, d F Y H:i:s')
|
||||||
|
->wrap(),
|
||||||
|
|
||||||
|
TextColumn::make('updated_at')
|
||||||
|
->label('Diperbarui')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true)
|
||||||
|
->dateTime('l, d F Y H:i:s')
|
||||||
|
->wrap(),
|
||||||
|
|
||||||
|
TextColumn::make('deleted_at')
|
||||||
|
->label('Dihapus')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true)
|
||||||
|
->dateTime('l, d F Y H:i:s')
|
||||||
|
->wrap(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -136,7 +136,7 @@ public function authenticate(): ?LoginResponse
|
|||||||
|
|
||||||
CheerfulNotification::success(
|
CheerfulNotification::success(
|
||||||
'Hore! Berhasil Masuk 🎉',
|
'Hore! Berhasil Masuk 🎉',
|
||||||
'Selamat datang kembali, ' . $user->name . '! Siap untuk beraksi hari ini? 🚀✨'
|
'Selamat datang kembali, '.$user->name.'! Siap untuk beraksi hari ini? 🚀✨'
|
||||||
)->send();
|
)->send();
|
||||||
|
|
||||||
return app(LoginResponse::class);
|
return app(LoginResponse::class);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user