simedkom/app/Filament/Resources/Manage/Cooperations/Actions/Report/RejectAction.php
Yoga Pangestu 6fe5e81717 refactor: add type hinting to closures and fix logic errors in Filament codebase
- Added comprehensive parameter and return type hinting to closures across various Filament resources, actions, and relation managers to improve type safety and static analysis.
- Fixed logic in ReportRelationManager where report count was incorrectly compared, preventing the 'Buat Laporan' button from showing correctly.
- Corrected namespaces for RepeatableEntry and TextEntry in ViewCooperation (changed from Filament\Schemas to Filament\Infolists).
- Fixed component rendering in JournalistResource form by ensuring sections are correctly returned in the mapping.
- Added @var docblocks to resolve lint errors related to auth()->user() and verified query builder return types.
- Standardized file retrieval logic in PartnerResource and improved overall code reliability."
2026-01-12 15:17:21 +07:00

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): void {
$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): bool => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING)
->modalWidth(Width::Large);
}
}