- 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."
58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Manage\Cooperations\RelationManagers;
|
|
|
|
use App\Filament\Resources\Manage\Partners\PartnerResource;
|
|
use App\Models\CooperationMedia;
|
|
use Filament\Actions\Action;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CooperationMediaRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'cooperationMedia';
|
|
|
|
protected static ?string $title = 'Media';
|
|
|
|
public static function canViewForRecord(Model $ownerRecord, string $pageClass): bool
|
|
{
|
|
return ! auth()->user()->hasRole('Perusahaan');
|
|
}
|
|
|
|
public static function getBadge(Model $ownerRecord, string $pageClass): ?string
|
|
{
|
|
return $ownerRecord->cooperationMedia()->count();
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->recordTitleAttribute('partnerMedia.name')
|
|
->columns([
|
|
TextColumn::make('partnerMedia.name')
|
|
->label('Nama')
|
|
->searchable(),
|
|
|
|
TextColumn::make('status')
|
|
->label('Status')
|
|
->badge(),
|
|
])
|
|
->filters([])
|
|
->headerActions([])
|
|
->recordActions([
|
|
Action::make('view')
|
|
->label('Lihat')
|
|
->icon(Heroicon::Eye)
|
|
->url(function (CooperationMedia $record): string {
|
|
return PartnerResource::getUrl('view', [
|
|
'record' => $record->partnerMedia->company->user_id,
|
|
]);
|
|
}),
|
|
])
|
|
->recordAction(null);
|
|
}
|
|
}
|