feat: add partner view page with detailed infolist and link from cooperation media manager
This commit is contained in:
parent
ee7192a087
commit
fcc09599e8
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Manage\Cooperations\RelationManagers;
|
namespace App\Filament\Resources\Manage\Cooperations\RelationManagers;
|
||||||
|
|
||||||
use Filament\Actions\ViewAction;
|
use App\Filament\Resources\Manage\Partners\PartnerResource;
|
||||||
|
use App\Models\CooperationMedia;
|
||||||
|
use Filament\Actions\Action;
|
||||||
use Filament\Resources\RelationManagers\RelationManager;
|
use Filament\Resources\RelationManagers\RelationManager;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
@ -35,9 +38,15 @@ public function table(Table $table): Table
|
|||||||
->filters([])
|
->filters([])
|
||||||
->headerActions([])
|
->headerActions([])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
ViewAction::make(),
|
Action::make('view')
|
||||||
|
->label('Lihat')
|
||||||
|
->icon(Heroicon::Eye)
|
||||||
|
->url(
|
||||||
|
fn (CooperationMedia $record): string => PartnerResource::getUrl('view', [
|
||||||
|
'record' => $record->partnerMedia->company->user_id,
|
||||||
|
])
|
||||||
|
),
|
||||||
])
|
])
|
||||||
->toolbarActions([])
|
|
||||||
->recordAction(null);
|
->recordAction(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
app/Filament/Resources/Manage/Partners/Pages/ViewPartner.php
Normal file
11
app/Filament/Resources/Manage/Partners/Pages/ViewPartner.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\Manage\Partners\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\Manage\Partners\PartnerResource;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewPartner extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = PartnerResource::class;
|
||||||
|
}
|
||||||
@ -3,25 +3,26 @@
|
|||||||
namespace App\Filament\Resources\Manage\Partners;
|
namespace App\Filament\Resources\Manage\Partners;
|
||||||
|
|
||||||
use App\Filament\Resources\Manage\Partners\Pages\ManagePartners;
|
use App\Filament\Resources\Manage\Partners\Pages\ManagePartners;
|
||||||
|
use App\Filament\Resources\Manage\Partners\Pages\ViewPartner;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\DeleteAction;
|
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
use Filament\Actions\EditAction;
|
|
||||||
use Filament\Actions\ForceDeleteAction;
|
|
||||||
use Filament\Actions\ForceDeleteBulkAction;
|
use Filament\Actions\ForceDeleteBulkAction;
|
||||||
use Filament\Actions\RestoreAction;
|
|
||||||
use Filament\Actions\RestoreBulkAction;
|
use Filament\Actions\RestoreBulkAction;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Actions\ViewAction;
|
||||||
|
use Filament\Infolists\Components\RepeatableEntry;
|
||||||
|
use Filament\Infolists\Components\TextEntry;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Components\Grid;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Support\Enums\Width;
|
|
||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Filters\TrashedFilter;
|
use Filament\Tables\Filters\TrashedFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Joaopaulolndev\FilamentPdfViewer\Infolists\Components\PdfViewerEntry;
|
||||||
use UnitEnum;
|
use UnitEnum;
|
||||||
|
|
||||||
class PartnerResource extends Resource
|
class PartnerResource extends Resource
|
||||||
@ -40,14 +41,235 @@ class PartnerResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $slug = 'manage/partners';
|
protected static ?string $slug = 'manage/partners';
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function infolist(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return $schema
|
return $schema
|
||||||
->components([
|
->schema([
|
||||||
TextInput::make('name')
|
Section::make('Akun')
|
||||||
->required()
|
->schema([
|
||||||
->maxLength(255),
|
Grid::make(3)
|
||||||
]);
|
->schema([
|
||||||
|
TextEntry::make('name')
|
||||||
|
->label('Nama'),
|
||||||
|
|
||||||
|
TextEntry::make('email')
|
||||||
|
->label('Email'),
|
||||||
|
|
||||||
|
TextEntry::make('username')
|
||||||
|
->label('Nama Pengguna'),
|
||||||
|
|
||||||
|
TextEntry::make('is_active')
|
||||||
|
->label('Status')
|
||||||
|
->badge(),
|
||||||
|
|
||||||
|
TextEntry::make('email_verified_at')
|
||||||
|
->label('Email Verifikasi')
|
||||||
|
->placeholder('Akun Belum Diverifikasi')
|
||||||
|
->dateTime('l, d F Y H:i'),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('Perusahaan')
|
||||||
|
->schema([
|
||||||
|
Grid::make(3)
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.name')
|
||||||
|
->label('Nama'),
|
||||||
|
|
||||||
|
TextEntry::make('company.email')
|
||||||
|
->label('Email'),
|
||||||
|
|
||||||
|
TextEntry::make('company.address')
|
||||||
|
->label('Alamat'),
|
||||||
|
|
||||||
|
TextEntry::make('company.director_name')
|
||||||
|
->label('Nama Direktur'),
|
||||||
|
|
||||||
|
TextEntry::make('company.validated_at')
|
||||||
|
->label('Tanggal Validasi')
|
||||||
|
->dateTime('d F Y H:i'),
|
||||||
|
|
||||||
|
TextEntry::make('company.rejection_reason')
|
||||||
|
->label('Alasan Penolakan')
|
||||||
|
->visible(fn ($record) => $record->company?->rejection_reason),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Grid::make(3)
|
||||||
|
->schema([
|
||||||
|
Section::make('NIK Direktur')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.director_nik')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
TextEntry::make('company.director_nik_docs')
|
||||||
|
->hiddenLabel()
|
||||||
|
->html()
|
||||||
|
->getStateUsing(function ($record) {
|
||||||
|
$media = $record->company
|
||||||
|
?->getMedia('companies')
|
||||||
|
->where('custom_properties.doc_type', 'director-nik')
|
||||||
|
->sortByDesc('created_at')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $media) {
|
||||||
|
return 'Tidak ada dokumen';
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $media->getUrl();
|
||||||
|
$mime = $media->mime_type;
|
||||||
|
|
||||||
|
if (str_contains($mime, 'image')) {
|
||||||
|
return '<img src="'.$url.'" alt="Dokumen NIK Direktur" style="max-width: 100%; height: auto; border-radius: 0.5rem;" />';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str_contains($mime, 'pdf')) {
|
||||||
|
return '<iframe src="'.$url.'" style="width: 100%; height: 500px; border: none;"></iframe>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '<a href="'.$url.'" target="_blank" class="text-primary-600 hover:text-primary-500 underline">Unduh Dokumen</a>';
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('Akta Pendirian')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.deed_incorporation')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
self::fileEntry('company.deed_incorporation'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('SIUP')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.trade_license')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
self::fileEntry('company.trade_license'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('NPWP')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.tax_id_number')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
self::fileEntry('company.tax_id_number'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('PKP')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.taxable_enterprise')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
self::fileEntry('company.taxable_enterprise'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('SPT Tahunan')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.annual_tax_return')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
self::fileEntry('company.annual_tax_return'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('SK Domisili')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.domicile_certificate')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
self::fileEntry('company.domicile_certificate'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('Profil Perusahaan')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.profile')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
self::fileEntry('company.profile'),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('Media')
|
||||||
|
->schema([
|
||||||
|
Grid::make(4)
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.partnerMedia.name')
|
||||||
|
->label('Nama'),
|
||||||
|
|
||||||
|
TextEntry::make('company.partnerMedia.link')
|
||||||
|
->label('Tautan')
|
||||||
|
->url(fn ($record) => $record->company?->partnerMedia?->link, true),
|
||||||
|
|
||||||
|
TextEntry::make('company.partnerMedia.type')
|
||||||
|
->label('Jenis')
|
||||||
|
->badge(),
|
||||||
|
|
||||||
|
TextEntry::make('company.partnerMedia.classification')
|
||||||
|
->label('Klasifikasi')
|
||||||
|
->badge(),
|
||||||
|
|
||||||
|
TextEntry::make('company.partnerMedia.address')
|
||||||
|
->label('Alamat')
|
||||||
|
->columnSpanFull(),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Grid::make(2)
|
||||||
|
->schema([
|
||||||
|
Section::make('Sertifikat Organisasi Kewartawanan')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.partnerMedia.journalism_organization')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
self::fileEntry('company.partnerMedia.journalism_organization', 'company.partnerMedia', 'partnerMedia'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('Sertifikat Dewan Pers')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('company.partnerMedia.press_council_certificate')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
self::fileEntry('company.partnerMedia.press_council_certificate', 'company.partnerMedia', 'partnerMedia'),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('Jurnalis')
|
||||||
|
->schema([
|
||||||
|
RepeatableEntry::make('company.partnerMedia.journalists')
|
||||||
|
->hiddenLabel()
|
||||||
|
->schema([
|
||||||
|
Grid::make(3)
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('name')
|
||||||
|
->label('Nama'),
|
||||||
|
|
||||||
|
TextEntry::make('email')
|
||||||
|
->label('Email'),
|
||||||
|
|
||||||
|
TextEntry::make('phone_number')
|
||||||
|
->label('No. Telepon'),
|
||||||
|
]),
|
||||||
|
Grid::make(2)
|
||||||
|
->schema([
|
||||||
|
Section::make('Kartu Pers')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('press_card')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
self::fileEntry('press_card', null, 'journalists'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make('Sertifikat UKW')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('ukw_certificate')
|
||||||
|
->hiddenLabel(),
|
||||||
|
|
||||||
|
self::fileEntry('ukw_certificate', null, 'journalists'),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
->columns(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
@ -59,7 +281,7 @@ public static function table(Table $table): Table
|
|||||||
->label('Perusahaan')
|
->label('Perusahaan')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable()
|
->sortable()
|
||||||
->description(fn (User $record) => $record->company?->director_name),
|
->description(fn (User $record) => 'Direktur: '.$record->company?->director_name),
|
||||||
|
|
||||||
TextColumn::make('company.partnerMedia.name')
|
TextColumn::make('company.partnerMedia.name')
|
||||||
->label('Media')
|
->label('Media')
|
||||||
@ -85,14 +307,7 @@ public static function table(Table $table): Table
|
|||||||
->native(false),
|
->native(false),
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make()
|
ViewAction::make(),
|
||||||
->modalWidth(Width::Large),
|
|
||||||
|
|
||||||
DeleteAction::make(),
|
|
||||||
|
|
||||||
ForceDeleteAction::make(),
|
|
||||||
|
|
||||||
RestoreAction::make(),
|
|
||||||
])
|
])
|
||||||
->toolbarActions([
|
->toolbarActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
@ -118,6 +333,33 @@ public static function getPages(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'index' => ManagePartners::route('/'),
|
'index' => ManagePartners::route('/'),
|
||||||
|
'view' => ViewPartner::route('/{record}'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function fileEntry(
|
||||||
|
string $name,
|
||||||
|
?string $mediaOwner = 'company',
|
||||||
|
string $collection = 'companies'
|
||||||
|
): PdfViewerEntry {
|
||||||
|
return PdfViewerEntry::make($name)
|
||||||
|
->hiddenLabel()
|
||||||
|
->getStateUsing(function ($record) use ($name, $mediaOwner, $collection) {
|
||||||
|
$owner = data_get($record, $mediaOwner);
|
||||||
|
|
||||||
|
if (! $owner) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$docType = str($name)
|
||||||
|
->afterLast('.')
|
||||||
|
->slug('-');
|
||||||
|
|
||||||
|
return $owner->getMedia($collection)
|
||||||
|
->where('custom_properties.doc_type', $docType)
|
||||||
|
->sortByDesc('created_at')
|
||||||
|
->first()
|
||||||
|
?->getUrl();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
"bezhansalleh/filament-shield": "^4.0",
|
"bezhansalleh/filament-shield": "^4.0",
|
||||||
"filament/filament": "^4.0",
|
"filament/filament": "^4.0",
|
||||||
"filament/spatie-laravel-media-library-plugin": "^4.0",
|
"filament/spatie-laravel-media-library-plugin": "^4.0",
|
||||||
|
"joaopaulolndev/filament-pdf-viewer": "^2.0",
|
||||||
"laravel/framework": "^12.0",
|
"laravel/framework": "^12.0",
|
||||||
"laravel/tinker": "^2.10.1",
|
"laravel/tinker": "^2.10.1",
|
||||||
"spatie/laravel-sluggable": "^3.7",
|
"spatie/laravel-sluggable": "^3.7",
|
||||||
|
|||||||
75
composer.lock
generated
75
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "cb99bc6f72a67719573fb6369e534728",
|
"content-hash": "c2c5addb8f0b597b5135fc66bf225efd",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "anourvalar/eloquent-serialize",
|
"name": "anourvalar/eloquent-serialize",
|
||||||
@ -2305,6 +2305,79 @@
|
|||||||
],
|
],
|
||||||
"time": "2025-08-22T14:27:06+00:00"
|
"time": "2025-08-22T14:27:06+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "joaopaulolndev/filament-pdf-viewer",
|
||||||
|
"version": "v2.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/joaopaulolndev/filament-pdf-viewer.git",
|
||||||
|
"reference": "381c2fbbced49788a57c97a3df56782a91bb23dc"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/joaopaulolndev/filament-pdf-viewer/zipball/381c2fbbced49788a57c97a3df56782a91bb23dc",
|
||||||
|
"reference": "381c2fbbced49788a57c97a3df56782a91bb23dc",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"filament/filament": "^4.0",
|
||||||
|
"php": "^8.2",
|
||||||
|
"spatie/laravel-package-tools": "^1.15.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"laravel/pint": "^1.0",
|
||||||
|
"nunomaduro/collision": "^7.9|^8.6",
|
||||||
|
"orchestra/testbench": "^8.0|^9.0|^10.0",
|
||||||
|
"pestphp/pest": "^2.1|^3.4.7",
|
||||||
|
"pestphp/pest-plugin-arch": "^2.0|^3.0",
|
||||||
|
"pestphp/pest-plugin-laravel": "^2.0|^3.1.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"aliases": {
|
||||||
|
"FilamentPdfViewer": "Joaopaulolndev\\FilamentPdfViewer\\Facades\\FilamentPdfViewer"
|
||||||
|
},
|
||||||
|
"providers": [
|
||||||
|
"Joaopaulolndev\\FilamentPdfViewer\\FilamentPdfViewerServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Joaopaulolndev\\FilamentPdfViewer\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "João Paulo Leite Nascimento",
|
||||||
|
"email": "joaopauloln7@gmail.com",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Filament package to show pdf document viewer",
|
||||||
|
"homepage": "https://github.com/joaopaulolndev/filament-pdf-viewer",
|
||||||
|
"keywords": [
|
||||||
|
"filament-pdf-viewer",
|
||||||
|
"joaopaulolndev",
|
||||||
|
"laravel"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/joaopaulolndev/filament-pdf-viewer/issues",
|
||||||
|
"source": "https://github.com/joaopaulolndev/filament-pdf-viewer"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/joaopaulolndev",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-08-09T21:11:21+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "kirschbaum-development/eloquent-power-joins",
|
"name": "kirschbaum-development/eloquent-power-joins",
|
||||||
"version": "4.2.10",
|
"version": "4.2.10",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user