- 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."
126 lines
4.7 KiB
PHP
126 lines
4.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Manage\Cooperations\RelationManagers;
|
|
|
|
use App\Enums\ApprovalStatus;
|
|
use App\Filament\Resources\Manage\Cooperations\Actions\Proposal\AcceptAction;
|
|
use App\Filament\Resources\Manage\Cooperations\Actions\Proposal\RejectAction;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\ViewAction;
|
|
use Filament\Infolists\Components\TextEntry;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
use Filament\Schemas\Components\Grid;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
use Joaopaulolndev\FilamentPdfViewer\Infolists\Components\PdfViewerEntry;
|
|
|
|
class CooperationProposalRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'proposals';
|
|
|
|
protected static ?string $title = 'Proposal';
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->recordTitleAttribute('e_catalog')
|
|
->columns([
|
|
TextColumn::make('partnerMedia.name')
|
|
->label('Media')
|
|
->searchable()
|
|
->visible(! auth()->user()->hasRole('Perusahaan')),
|
|
|
|
TextColumn::make('e_catalog')
|
|
->label('E-Catalog')
|
|
->url(fn (\App\Models\CooperationProposal $record): ?string => $record->e_catalog)
|
|
->openUrlInNewTab()
|
|
->color('primary'),
|
|
|
|
TextColumn::make('description')
|
|
->label('Deskripsi'),
|
|
|
|
TextColumn::make('status')
|
|
->label('Status')
|
|
->badge(),
|
|
|
|
TextColumn::make('submitted_at')
|
|
->label('Diajukan')
|
|
->dateTime('l, d F Y H:i:s')
|
|
->sortable(),
|
|
|
|
TextColumn::make('responded_at')
|
|
->label('Ditanggapi')
|
|
->dateTime('l, d F Y H:i:s')
|
|
->sortable(),
|
|
|
|
TextColumn::make('rejectionReasons.reason')
|
|
->label('Alasan Penolakan')
|
|
->searchable(),
|
|
])
|
|
->filters([])
|
|
->headerActions([])
|
|
->recordActions([
|
|
ViewAction::make(),
|
|
|
|
AcceptAction::make('accept'),
|
|
|
|
RejectAction::make('reject'),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public function infolist(Schema $infolist): Schema
|
|
{
|
|
return $infolist
|
|
->components([
|
|
Grid::make(2)
|
|
->schema([
|
|
TextEntry::make('partnerMedia.name')
|
|
->label('Media')
|
|
->visible(! auth()->user()->hasRole('Perusahaan')),
|
|
|
|
TextEntry::make('status')
|
|
->label('Status')
|
|
->badge(),
|
|
|
|
TextEntry::make('submitted_at')
|
|
->label('Diajukan')
|
|
->dateTime('l, d F Y H:i:s'),
|
|
|
|
TextEntry::make('responded_at')
|
|
->label('Ditanggapi')
|
|
->dateTime('l, d F Y H:i:s'),
|
|
]),
|
|
|
|
TextEntry::make('e_catalog')
|
|
->label('E-Catalog')
|
|
->url(fn (\App\Models\CooperationProposal $record): ?string => $record->e_catalog)
|
|
->openUrlInNewTab()
|
|
->color('primary')
|
|
->visible(fn (\App\Models\CooperationProposal $record): ?string => $record->e_catalog),
|
|
|
|
TextEntry::make('description')
|
|
->label('Deskripsi')
|
|
->columnSpanFull(),
|
|
|
|
PdfViewerEntry::make('proposal_attachment')
|
|
->label('Lampiran Proposal')
|
|
->getStateUsing(fn (\App\Models\CooperationProposal $record): ?string => optional($record->getMedia('cooperations')->where('custom_properties.doc_type', 'proposal-attachment')->sortByDesc('created_at')->first())->getPathRelativeToRoot())
|
|
->disk(config('filesystems.default')),
|
|
|
|
TextEntry::make('rejectionReasons.reason')
|
|
->label('Alasan Penolakan')
|
|
->listWithLineBreaks()
|
|
->visible(fn (\App\Models\CooperationProposal $record): bool => $record->status === ApprovalStatus::REJECTED && $record->rejectionReasons->isNotEmpty())
|
|
->columnSpanFull(),
|
|
])
|
|
->columns(1);
|
|
}
|
|
}
|