- Refactor custom Filament actions into resource-specific subfolders (Cooperation, Proposal, Report).
- Standardize all action identifiers to snake_case for consistency.
- Move action identifiers directly into ::make('name') calls.
- Remove getDefaultName() from custom action classes to favor explicit naming.
- Update relation managers and resources to use the new namespaced action classes.
- Standardize closure syntax (fn) and string formatting across schemas and actions.
34 lines
988 B
PHP
34 lines
988 B
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Manage\Cooperations\Actions\Report;
|
|
|
|
use App\Enums\ApprovalStatus;
|
|
use App\Models\Report;
|
|
use Filament\Actions\Action;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Support\Icons\Heroicon;
|
|
|
|
class AcceptAction extends Action
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->label('Terima')
|
|
->icon(Heroicon::OutlinedCheck)
|
|
->color('success')
|
|
->action(function (Report $record) {
|
|
$record->update([
|
|
'status' => ApprovalStatus::ACCEPTED,
|
|
]);
|
|
|
|
Notification::make()
|
|
->title('Laporan Diterima')
|
|
->body("Laporan '{$record->title}' telah diterima.")
|
|
->success()
|
|
->send();
|
|
})
|
|
->visible(fn (Report $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING);
|
|
}
|
|
}
|