mirror of
https://github.com/openclassify/openclassify.git
synced 2026-04-14 11:12:09 -05:00
Refactor modular Laravel Filament
This commit is contained in:
parent
89003f45e1
commit
222928d1d9
@ -94,7 +94,7 @@ class Video extends Model
|
||||
|
||||
public static function createFromTemporaryUpload(Listing $listing, TemporaryUploadedFile $file, array $attributes = []): self
|
||||
{
|
||||
$disk = (string) config('video.disk', MediaStorage::activeDisk());
|
||||
$disk = (string) ($attributes['disk'] ?? config('video.disk', MediaStorage::activeDisk()));
|
||||
$path = $file->storeAs(
|
||||
trim((string) config('video.upload_directory', 'videos/uploads').'/'.$listing->getKey(), '/'),
|
||||
Str::ulid().'.'.($file->getClientOriginalExtension() ?: $file->guessExtension() ?: 'mp4'),
|
||||
@ -117,7 +117,7 @@ class Video extends Model
|
||||
|
||||
public static function createFromUploadedFile(Listing $listing, UploadedFile $file, array $attributes = []): self
|
||||
{
|
||||
$disk = (string) config('video.disk', MediaStorage::activeDisk());
|
||||
$disk = (string) ($attributes['disk'] ?? config('video.disk', MediaStorage::activeDisk()));
|
||||
$path = $file->storeAs(
|
||||
trim((string) config('video.upload_directory', 'videos/uploads').'/'.$listing->getKey(), '/'),
|
||||
Str::ulid().'.'.($file->getClientOriginalExtension() ?: $file->extension() ?: 'mp4'),
|
||||
|
||||
@ -17,6 +17,7 @@ use Modules\Listing\Support\ListingCustomFieldSchemaBuilder;
|
||||
use Modules\Listing\Support\ListingPanelHelper;
|
||||
use Modules\Location\Models\City;
|
||||
use Modules\Location\Models\Country;
|
||||
use Modules\S3\Support\MediaStorage;
|
||||
use Modules\User\App\Models\Profile;
|
||||
use Modules\Video\Models\Video;
|
||||
use Throwable;
|
||||
@ -570,6 +571,7 @@ class PanelQuickListingForm extends Component
|
||||
];
|
||||
|
||||
$listing = Listing::createFromFrontend($payload, $user->getKey());
|
||||
$mediaDisk = $this->frontendMediaDisk();
|
||||
|
||||
foreach ($this->photos as $photo) {
|
||||
if (! $photo instanceof TemporaryUploadedFile) {
|
||||
@ -579,7 +581,7 @@ class PanelQuickListingForm extends Component
|
||||
$listing
|
||||
->addMedia($photo->getRealPath())
|
||||
->usingFileName($photo->getClientOriginalName())
|
||||
->toMediaCollection('listing-images');
|
||||
->toMediaCollection('listing-images', $mediaDisk);
|
||||
}
|
||||
|
||||
foreach ($this->videos as $index => $video) {
|
||||
@ -588,6 +590,7 @@ class PanelQuickListingForm extends Component
|
||||
}
|
||||
|
||||
Video::createFromTemporaryUpload($listing, $video, [
|
||||
'disk' => $mediaDisk,
|
||||
'sort_order' => $index + 1,
|
||||
'title' => pathinfo($video->getClientOriginalName(), PATHINFO_FILENAME),
|
||||
]);
|
||||
@ -746,6 +749,11 @@ class PanelQuickListingForm extends Component
|
||||
return collect($this->categories)->contains(fn (array $category): bool => $category['id'] === $categoryId);
|
||||
}
|
||||
|
||||
private function frontendMediaDisk(): string
|
||||
{
|
||||
return (string) config('media_storage.local_disk', MediaStorage::diskFromDriver(MediaStorage::DRIVER_LOCAL));
|
||||
}
|
||||
|
||||
private function categoryPathParts(int $categoryId): array
|
||||
{
|
||||
$byId = collect($this->categories)->keyBy('id');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user