feat: Refactor media handling and improve file upload configurations in Cooperation and Journalist resources
This commit is contained in:
parent
b97b8a3708
commit
6265410fb0
@ -136,9 +136,9 @@ public static function infolist(Schema $schema): Schema
|
|||||||
|
|
||||||
ImageEntry::make('banner')
|
ImageEntry::make('banner')
|
||||||
->label('Banner')
|
->label('Banner')
|
||||||
->getStateUsing(fn ($record) => optional($record->getMedia('banners')->sortByDesc('created_at')->first())->getPathRelativeToRoot())
|
->getStateUsing(fn ($record) => optional($record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->sortByDesc('created_at')->first())->getPathRelativeToRoot())
|
||||||
->disk(config('filesystems.default'))
|
->disk(config('filesystems.default'))
|
||||||
->visible(fn ($record) => $record->getMedia('banners')->isNotEmpty()),
|
->visible(fn ($record) => $record->getMedia('cooperations')->isNotEmpty()),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
TextEntry::make('description')
|
TextEntry::make('description')
|
||||||
|
|||||||
@ -39,6 +39,7 @@ protected function afterCreate(): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
$filePath = collect($data['proposal_template'])->first();
|
$filePath = collect($data['proposal_template'])->first();
|
||||||
|
dd($filePath);
|
||||||
|
|
||||||
$fullPath = Storage::disk(config('filesystems.default'))->path($filePath);
|
$fullPath = Storage::disk(config('filesystems.default'))->path($filePath);
|
||||||
|
|
||||||
|
|||||||
@ -69,8 +69,8 @@ protected function afterSave(): void
|
|||||||
->preservingOriginal()
|
->preservingOriginal()
|
||||||
->withCustomProperties([
|
->withCustomProperties([
|
||||||
'feature' => 'cooperations',
|
'feature' => 'cooperations',
|
||||||
'date' => now()->toDateString(),
|
|
||||||
'doc_type' => 'proposal-template',
|
'doc_type' => 'proposal-template',
|
||||||
|
'date' => now()->toDateString(),
|
||||||
])
|
])
|
||||||
->toMediaCollection('cooperations');
|
->toMediaCollection('cooperations');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,7 +84,12 @@ public static function configure(Schema $schema): Schema
|
|||||||
->disk(config('filesystems.default'))
|
->disk(config('filesystems.default'))
|
||||||
->acceptedFileTypes(['image/*'])
|
->acceptedFileTypes(['image/*'])
|
||||||
->maxSize(1024 * 3)
|
->maxSize(1024 * 3)
|
||||||
->collection('banners')
|
->collection('cooperations')
|
||||||
|
->customProperties(fn () => [
|
||||||
|
'feature' => 'cooperations',
|
||||||
|
'doc_type' => 'banner',
|
||||||
|
'date' => now()->toDateString(),
|
||||||
|
])
|
||||||
->image(),
|
->image(),
|
||||||
|
|
||||||
AdvancedFileUpload::make('proposal_template')
|
AdvancedFileUpload::make('proposal_template')
|
||||||
@ -92,7 +97,7 @@ public static function configure(Schema $schema): Schema
|
|||||||
->disk(config('filesystems.default'))
|
->disk(config('filesystems.default'))
|
||||||
->acceptedFileTypes(['application/pdf'])
|
->acceptedFileTypes(['application/pdf'])
|
||||||
->maxSize(1024 * 10)
|
->maxSize(1024 * 10)
|
||||||
->directory('cooperations/templates/'.now()->toDateString())
|
->directory(fn () => 'cooperations/proposal-template/'.now()->toDateString())
|
||||||
->required(),
|
->required(),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
|
|||||||
@ -90,9 +90,9 @@ public static function configure(Table $table): Table
|
|||||||
->html()
|
->html()
|
||||||
->getStateUsing(function (Cooperation $record) {
|
->getStateUsing(function (Cooperation $record) {
|
||||||
$record->loadCount([
|
$record->loadCount([
|
||||||
'partnerMedia as approved_count' => fn ($query) => $query->where('cooperations.status', ApprovalStatus::ACCEPTED),
|
'partnerMedia as approved_count' => fn ($query) => $query->where('cooperation_media.status', ApprovalStatus::ACCEPTED),
|
||||||
'partnerMedia as rejected_count' => fn ($query) => $query->where('cooperations.status', ApprovalStatus::REJECTED),
|
'partnerMedia as rejected_count' => fn ($query) => $query->where('cooperation_media.status', ApprovalStatus::REJECTED),
|
||||||
'partnerMedia as pending_count' => fn ($query) => $query->where('cooperations.status', ApprovalStatus::PENDING),
|
'partnerMedia as pending_count' => fn ($query) => $query->where('cooperation_media.status', ApprovalStatus::PENDING),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$totalCount = $record->partnerMedia()->count();
|
$totalCount = $record->partnerMedia()->count();
|
||||||
@ -241,18 +241,18 @@ public static function configure(Table $table): Table
|
|||||||
->url(),
|
->url(),
|
||||||
|
|
||||||
Textarea::make('description')
|
Textarea::make('description')
|
||||||
->label('Deskripsi Proposal')
|
->label('Deskripsi')
|
||||||
->autocomplete(false)
|
->autocomplete(false)
|
||||||
->required()
|
->required()
|
||||||
->rows(4)
|
->rows(4)
|
||||||
->placeholder('...'),
|
->placeholder('...'),
|
||||||
|
|
||||||
AdvancedFileUpload::make('proposal_attachment')
|
AdvancedFileUpload::make('proposal_attachment')
|
||||||
->label('Lampiran Proposal')
|
->label('Lampiran')
|
||||||
->disk(config('filesystems.default'))
|
->disk(config('filesystems.default'))
|
||||||
->acceptedFileTypes(['application/pdf'])
|
->acceptedFileTypes(['application/pdf'])
|
||||||
->maxSize(1024 * 10)
|
->maxSize(1024 * 10)
|
||||||
->directory('cooperation/proposal/'.now()->toDateString())
|
->directory(fn () => 'cooperations/proposal-attachment/'.now()->toDateString())
|
||||||
->required(),
|
->required(),
|
||||||
])
|
])
|
||||||
->action(function ($record, array $data) {
|
->action(function ($record, array $data) {
|
||||||
|
|||||||
@ -60,7 +60,7 @@ public static function form(Schema $schema): Schema
|
|||||||
'max_size' => 1024 * 10,
|
'max_size' => 1024 * 10,
|
||||||
'file_name' => 'press_card_docs',
|
'file_name' => 'press_card_docs',
|
||||||
'accept' => ['application/pdf'],
|
'accept' => ['application/pdf'],
|
||||||
'folder' => 'journalists/press-card/',
|
'folder' => 'press-card/',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'title' => 'Sertifikat UKW',
|
'title' => 'Sertifikat UKW',
|
||||||
@ -70,7 +70,7 @@ public static function form(Schema $schema): Schema
|
|||||||
'max_size' => 1024 * 10,
|
'max_size' => 1024 * 10,
|
||||||
'file_name' => 'ukw_certificate_docs',
|
'file_name' => 'ukw_certificate_docs',
|
||||||
'accept' => ['application/pdf'],
|
'accept' => ['application/pdf'],
|
||||||
'folder' => 'journalists/ukw-certificate/',
|
'folder' => 'ukw-certificate/',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -119,6 +119,7 @@ public static function form(Schema $schema): Schema
|
|||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
->disk(config('filesystems.default'))
|
->disk(config('filesystems.default'))
|
||||||
->acceptedFileTypes($doc['accept'])
|
->acceptedFileTypes($doc['accept'])
|
||||||
|
->directory(fn () => 'journalists/'.$doc['folder'].now()->toDateString())
|
||||||
->maxSize($doc['max_size'])
|
->maxSize($doc['max_size'])
|
||||||
->required(),
|
->required(),
|
||||||
])
|
])
|
||||||
|
|||||||
@ -82,6 +82,10 @@ public static function configure(Schema $schema): Schema
|
|||||||
->acceptedFileTypes(['image/*'])
|
->acceptedFileTypes(['image/*'])
|
||||||
->maxSize(1024 * 3)
|
->maxSize(1024 * 3)
|
||||||
->collection('content-recpaps')
|
->collection('content-recpaps')
|
||||||
|
->customProperties(fn () => [
|
||||||
|
'feature' => 'content-recaps',
|
||||||
|
'date' => now()->toDateString(),
|
||||||
|
])
|
||||||
->image()
|
->image()
|
||||||
->required(),
|
->required(),
|
||||||
]),
|
]),
|
||||||
|
|||||||
@ -24,6 +24,11 @@ protected function getHeaderActions(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRedirectUrl(): string
|
||||||
|
{
|
||||||
|
return $this->getResource()::getUrl('index');
|
||||||
|
}
|
||||||
|
|
||||||
protected function mutateFormDataBeforeCreate(array $data): array
|
protected function mutateFormDataBeforeCreate(array $data): array
|
||||||
{
|
{
|
||||||
$latestCode = MediaMonitoring::max('code');
|
$latestCode = MediaMonitoring::max('code');
|
||||||
|
|||||||
@ -113,6 +113,10 @@ public static function configure(Schema $schema): Schema
|
|||||||
->acceptedFileTypes(['image/*'])
|
->acceptedFileTypes(['image/*'])
|
||||||
->maxSize(1024 * 3)
|
->maxSize(1024 * 3)
|
||||||
->collection('media-monitorings')
|
->collection('media-monitorings')
|
||||||
|
->customProperties(fn () => [
|
||||||
|
'feature' => 'media-monitorings',
|
||||||
|
'date' => now()->toDateString(),
|
||||||
|
])
|
||||||
->image()
|
->image()
|
||||||
->required(),
|
->required(),
|
||||||
]),
|
]),
|
||||||
|
|||||||
@ -96,6 +96,10 @@ public static function configure(Schema $schema): Schema
|
|||||||
->acceptedFileTypes(['image/*'])
|
->acceptedFileTypes(['image/*'])
|
||||||
->maxSize(1024 * 3)
|
->maxSize(1024 * 3)
|
||||||
->collection('news')
|
->collection('news')
|
||||||
|
->customProperties(fn () => [
|
||||||
|
'feature' => 'news',
|
||||||
|
'date' => now()->toDateString(),
|
||||||
|
])
|
||||||
->image()
|
->image()
|
||||||
->required(),
|
->required(),
|
||||||
]),
|
]),
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Spatie\MediaLibrary\HasMedia;
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||||
@ -52,7 +53,7 @@ public function partnerMedia(): BelongsToMany
|
|||||||
->withTimestamps();
|
->withTimestamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reports(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
public function reports(): HasManyThrough
|
||||||
{
|
{
|
||||||
return $this->hasManyThrough(Report::class, TaskAssignment::class);
|
return $this->hasManyThrough(Report::class, TaskAssignment::class);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user