- Removed debug statement from CreateCooperation.php. - Updated CooperationProposalRelationManager to include a detailed infolist schema with media and status information. - Improved proposal creation logic in CooperationsTable to handle proposal attachments and store them in the media library. - Implemented media handling in CooperationProposal model for better integration with file uploads.
60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Manage\Cooperations\Pages;
|
|
|
|
use App\Filament\Resources\Manage\Cooperations\CooperationResource;
|
|
use Filament\Actions\Action;
|
|
use Filament\Resources\Pages\CreateRecord;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class CreateCooperation extends CreateRecord
|
|
{
|
|
protected static string $resource = CooperationResource::class;
|
|
|
|
protected static ?string $title = 'Tambah Kerja Sama';
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('back')
|
|
->label('Kembali')
|
|
->url(ListCooperations::getUrl())
|
|
->outlined()
|
|
->color('secondary'),
|
|
];
|
|
}
|
|
|
|
protected function getRedirectUrl(): string
|
|
{
|
|
return $this->getResource()::getUrl('index');
|
|
}
|
|
|
|
protected function afterCreate(): void
|
|
{
|
|
$record = $this->getRecord();
|
|
$data = $this->data;
|
|
|
|
if (empty($data['proposal_template'])) {
|
|
return;
|
|
}
|
|
|
|
$filePath = collect($data['proposal_template'])->first();
|
|
|
|
$fullPath = Storage::disk(config('filesystems.default'))->path($filePath);
|
|
|
|
if (! file_exists($fullPath)) {
|
|
return;
|
|
}
|
|
|
|
$record
|
|
->addMediaFromDisk($filePath, config('filesystems.default'))
|
|
->preservingOriginal()
|
|
->withCustomProperties([
|
|
'feature' => 'cooperations',
|
|
'date' => now()->toDateString(),
|
|
'doc_type' => 'proposal-template',
|
|
])
|
|
->toMediaCollection('cooperations');
|
|
}
|
|
}
|