- 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."
53 lines
2.0 KiB
PHP
53 lines
2.0 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 AcceptAction extends Action
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->label('Terima')
|
|
->icon(Heroicon::OutlinedCheck)
|
|
->color('success')
|
|
->action(function (\App\Models\Cooperation $record): void {
|
|
$cooperationMedia = $record->cooperationMedia()
|
|
->whereHas('partnerMedia', function (\Illuminate\Database\Eloquent\Builder $query): void {
|
|
$query->whereHas('company', function (\Illuminate\Database\Eloquent\Builder $subQuery): void {
|
|
$subQuery->where('user_id', auth()->id());
|
|
});
|
|
})
|
|
->first();
|
|
|
|
if ($cooperationMedia) {
|
|
$cooperationMedia->update(['status' => ApprovalStatus::ACCEPTED]);
|
|
Notification::make()
|
|
->title('Kerja sama diterima')
|
|
->success()
|
|
->send();
|
|
}
|
|
})
|
|
->visible(function (\App\Models\Cooperation $record): bool {
|
|
if (! auth()->user()->hasRole('Perusahaan')) {
|
|
return false;
|
|
}
|
|
|
|
$cooperationMedia = $record->cooperationMedia()
|
|
->whereHas('partnerMedia', function (\Illuminate\Database\Eloquent\Builder $query): void {
|
|
$query->whereHas('company', function (\Illuminate\Database\Eloquent\Builder $subQuery): void {
|
|
$subQuery->where('user_id', auth()->id());
|
|
});
|
|
})
|
|
->first();
|
|
|
|
return $cooperationMedia && $cooperationMedia->status === ApprovalStatus::PENDING;
|
|
});
|
|
}
|
|
}
|