31 lines
709 B
PHP
31 lines
709 B
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Queue\Queueable;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class PublishPublicMedia implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(public string $path) {}
|
|
|
|
public function handle(): void
|
|
{
|
|
if (str_contains($this->path, '..') || ! str_starts_with($this->path, 'cms/')) {
|
|
return;
|
|
}
|
|
|
|
$incoming = Storage::disk('cms_incoming');
|
|
|
|
if (! $incoming->exists($this->path)) {
|
|
return;
|
|
}
|
|
|
|
Storage::disk('media_public')->put($this->path, $incoming->get($this->path));
|
|
$incoming->delete($this->path);
|
|
}
|
|
}
|