feat: update assignment file handling to use temporary storage, include custom media properties, and remove redundant file preservation
This commit is contained in:
parent
80c1da3d5d
commit
b13133ce71
@ -79,7 +79,6 @@ public function handleRecordCreation(array $data): Model
|
|||||||
$filePath = is_array($pdf) ? reset($pdf) : $pdf;
|
$filePath = is_array($pdf) ? reset($pdf) : $pdf;
|
||||||
|
|
||||||
$assignment->addMediaFromDisk($filePath, config('filesystems.default'))
|
$assignment->addMediaFromDisk($filePath, config('filesystems.default'))
|
||||||
->preservingOriginal()
|
|
||||||
->withCustomProperties([
|
->withCustomProperties([
|
||||||
'feature' => 'assignments',
|
'feature' => 'assignments',
|
||||||
'date' => now()->toDateString(),
|
'date' => now()->toDateString(),
|
||||||
|
|||||||
@ -102,7 +102,6 @@ public function handleRecordUpdate(Model $record, array $data): Model
|
|||||||
|
|
||||||
if (! empty($filePath)) {
|
if (! empty($filePath)) {
|
||||||
$record->addMediaFromDisk($filePath, config('filesystems.default'))
|
$record->addMediaFromDisk($filePath, config('filesystems.default'))
|
||||||
->preservingOriginal()
|
|
||||||
->withCustomProperties([
|
->withCustomProperties([
|
||||||
'feature' => 'assignments',
|
'feature' => 'assignments',
|
||||||
'date' => now()->toDateString(),
|
'date' => now()->toDateString(),
|
||||||
|
|||||||
@ -264,6 +264,11 @@ public function submit(): void
|
|||||||
if ($state['file']) {
|
if ($state['file']) {
|
||||||
$existingSubmission->clearMediaCollection('submission');
|
$existingSubmission->clearMediaCollection('submission');
|
||||||
$existingSubmission->addMediaFromDisk($state['file'], config('filesystems.default'))
|
$existingSubmission->addMediaFromDisk($state['file'], config('filesystems.default'))
|
||||||
|
->withCustomProperties([
|
||||||
|
'feature' => 'assignments',
|
||||||
|
'date' => now()->toDateString(),
|
||||||
|
'doc_type' => 'submission',
|
||||||
|
])
|
||||||
->toMediaCollection('submission');
|
->toMediaCollection('submission');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,6 +288,11 @@ public function submit(): void
|
|||||||
|
|
||||||
if ($state['file']) {
|
if ($state['file']) {
|
||||||
$submission->addMediaFromDisk($state['file'], config('filesystems.default'))
|
$submission->addMediaFromDisk($state['file'], config('filesystems.default'))
|
||||||
|
->withCustomProperties([
|
||||||
|
'feature' => 'assignments',
|
||||||
|
'date' => now()->toDateString(),
|
||||||
|
'doc_type' => 'submission',
|
||||||
|
])
|
||||||
->toMediaCollection('submission');
|
->toMediaCollection('submission');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -121,7 +121,7 @@ public static function configure(Schema $schema): Schema
|
|||||||
->disk(config('filesystems.default'))
|
->disk(config('filesystems.default'))
|
||||||
->acceptedFileTypes(['application/pdf'])
|
->acceptedFileTypes(['application/pdf'])
|
||||||
->maxSize(1024 * 5)
|
->maxSize(1024 * 5)
|
||||||
->directory('assignments/'.now()->toDateString())
|
->directory('assignments-tmp/'.now()->toDateString())
|
||||||
->nullable()
|
->nullable()
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
])
|
])
|
||||||
|
|||||||
2
storage/app/public/.gitignore
vendored
2
storage/app/public/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
*
|
|
||||||
!.gitignore
|
|
||||||
Loading…
Reference in New Issue
Block a user