- 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.
45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Manage\Cooperations\Actions\Report;
|
|
|
|
use App\Enums\ApprovalStatus;
|
|
use App\Models\Report;
|
|
use Filament\Actions\Action;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Support\Enums\Width;
|
|
use Filament\Support\Icons\Heroicon;
|
|
|
|
class RejectAction extends Action
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->label('Tolak')
|
|
->icon(Heroicon::XMark)
|
|
->color('danger')
|
|
->schema([
|
|
Textarea::make('reason')
|
|
->label('Alasan Penolakan')
|
|
->placeholder('...')
|
|
->required(),
|
|
])
|
|
->action(function (Report $record, array $data) {
|
|
$record->update([
|
|
'status' => ApprovalStatus::REJECTED,
|
|
]);
|
|
|
|
$record->rejectionReasons()->create(['reason' => $data['reason']]);
|
|
|
|
Notification::make()
|
|
->title('Laporan Ditolak')
|
|
->body("Laporan '{$record->title}' telah ditolak.")
|
|
->warning()
|
|
->send();
|
|
})
|
|
->visible(fn (Report $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING)
|
|
->modalWidth(Width::Large);
|
|
}
|
|
}
|