- 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.
53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Manage\Cooperations\Actions\Cooperation;
|
|
|
|
use App\Enums\ApprovalStatus;
|
|
use Filament\Actions\Action;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Support\Icons\Heroicon;
|
|
|
|
class RejectAction extends Action
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->label('Tolak')
|
|
->icon(Heroicon::XMark)
|
|
->color('danger')
|
|
->action(function ($record) {
|
|
$cooperationMedia = $record->cooperationMedia()
|
|
->whereHas('partnerMedia', function ($query) {
|
|
$query->whereHas('company', function ($subQuery) {
|
|
$subQuery->where('user_id', auth()->id());
|
|
});
|
|
})
|
|
->first();
|
|
|
|
if ($cooperationMedia) {
|
|
$cooperationMedia->update(['status' => ApprovalStatus::REJECTED]);
|
|
Notification::make()
|
|
->title('Kerja sama ditolak')
|
|
->success()
|
|
->send();
|
|
}
|
|
})
|
|
->visible(function ($record) {
|
|
if (! auth()->user()->hasRole('Perusahaan')) {
|
|
return false;
|
|
}
|
|
|
|
$cooperationMedia = $record->cooperationMedia()
|
|
->whereHas('partnerMedia', function ($query) {
|
|
$query->whereHas('company', function ($subQuery) {
|
|
$subQuery->where('user_id', auth()->id());
|
|
});
|
|
})
|
|
->first();
|
|
|
|
return $cooperationMedia && $cooperationMedia->status === ApprovalStatus::PENDING;
|
|
});
|
|
}
|
|
}
|