Merge pull request 'MTM Laravel v12' (#31) from develop into main
Some checks failed
Deploy / Deploy (release) Has been cancelled

Reviewed-on: #31
This commit is contained in:
Jonny Barnes 2025-04-04 18:10:46 +02:00
commit 07db68882b
101 changed files with 2134 additions and 2938 deletions

View file

@ -12,7 +12,9 @@ APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database # APP_MAINTENANCE_STORE=database
PHP_CLI_SERVER_WORKERS=4
BCRYPT_ROUNDS=12 BCRYPT_ROUNDS=12
@ -39,7 +41,7 @@ FILESYSTEM_DISK=local
QUEUE_CONNECTION=database QUEUE_CONNECTION=database
CACHE_STORE=database CACHE_STORE=database
CACHE_PREFIX= # CACHE_PREFIX=
MEMCACHED_HOST=127.0.0.1 MEMCACHED_HOST=127.0.0.1
@ -49,6 +51,7 @@ REDIS_PASSWORD=null
REDIS_PORT=6379 REDIS_PORT=6379
MAIL_MAILER=log MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1 MAIL_HOST=127.0.0.1
MAIL_PORT=2525 MAIL_PORT=2525
MAIL_USERNAME=null MAIL_USERNAME=null

View file

@ -32,18 +32,21 @@ class ProcessMedia implements ShouldQueue
*/ */
public function handle(ImageManager $manager): void public function handle(ImageManager $manager): void
{ {
// Load file
$file = Storage::disk('local')->get('media/' . $this->filename);
// Open file // Open file
try { try {
$image = $manager->read(storage_path('app/media/') . $this->filename); $image = $manager->read($file);
} catch (DecoderException) { } catch (DecoderException) {
// not an image; delete file and end job // not an image; delete file and end job
unlink(storage_path('app/media/') . $this->filename); Storage::disk('local')->delete('media/' . $this->filename);
return; return;
} }
// Save the file publicly // Save the file publicly
Storage::disk('local')->copy('media/' . $this->filename, 'public/media/' . $this->filename); Storage::disk('public')->put('media/' . $this->filename, $file);
// Create smaller versions if necessary // Create smaller versions if necessary
if ($image->width() > 1000) { if ($image->width() > 1000) {
@ -54,13 +57,13 @@ class ProcessMedia implements ShouldQueue
$basename = trim(implode('.', $filenameParts), '.'); $basename = trim(implode('.', $filenameParts), '.');
$medium = $image->resize(width: 1000); $medium = $image->resize(width: 1000);
Storage::disk('local')->put('public/media/' . $basename . '-medium.' . $extension, (string) $medium->encode()); Storage::disk('public')->put('media/' . $basename . '-medium.' . $extension, (string) $medium->encode());
$small = $image->resize(width: 500); $small = $image->resize(width: 500);
Storage::disk('local')->put('public/media/' . $basename . '-small.' . $extension, (string) $small->encode()); Storage::disk('public')->put('media/' . $basename . '-small.' . $extension, (string) $small->encode());
} }
// Now we can delete the locally saved image // Now we can delete the locally saved image
unlink(storage_path('app/media/') . $this->filename); Storage::disk('local')->delete('media/' . $this->filename);
} }
} }

Some files were not shown because too many files have changed in this diff Show more