feat: Change Company partnerMedia relationship to HasOne and enhance PartnerResource company description display.
This commit is contained in:
parent
9ce3d72153
commit
ef446ef862
@ -20,6 +20,8 @@
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Joaopaulolndev\FilamentPdfViewer\Infolists\Components\PdfViewerEntry;
|
||||
use UnitEnum;
|
||||
|
||||
@ -278,7 +280,12 @@ public static function table(Table $table): Table
|
||||
->label('Perusahaan')
|
||||
->searchable()
|
||||
->sortable()
|
||||
->description(fn (User $record): string => 'Direktur: '.$record->company?->director_name),
|
||||
->description(
|
||||
fn (User $record) => new HtmlString(
|
||||
'Akun: '.$record->name.
|
||||
'<br/>Direktur: '.$record->company?->director_name
|
||||
)
|
||||
),
|
||||
|
||||
TextColumn::make('company.partnerMedia.name')
|
||||
->label('Media')
|
||||
@ -342,7 +349,7 @@ private static function fileEntry(
|
||||
): PdfViewerEntry {
|
||||
return PdfViewerEntry::make($name)
|
||||
->hiddenLabel()
|
||||
->getStateUsing(function (\Illuminate\Database\Eloquent\Model $record) use ($name, $mediaOwner, $collection): ?string {
|
||||
->getStateUsing(function (Model $record) use ($name, $mediaOwner, $collection): ?string {
|
||||
$owner = data_get($record, $mediaOwner);
|
||||
|
||||
if (! $owner) {
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
@ -31,9 +32,9 @@ public function journalists(): HasManyThrough
|
||||
return $this->hasManyThrough(Journalist::class, PartnerMedia::class);
|
||||
}
|
||||
|
||||
public function partnerMedias(): HasMany
|
||||
public function partnerMedia(): HasOne
|
||||
{
|
||||
return $this->hasMany(PartnerMedia::class);
|
||||
return $this->hasOne(PartnerMedia::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
|
||||
Loading…
Reference in New Issue
Block a user