Hi there,
im using the latest versions of laravel and livewire.
I have an existing Image model and i want to move the images to the media library, so i wanted to dispatch a job foreach existing image like so:
class MoveReleaseImage implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*/
public function __construct( public Image $image )
{
//
}
/**
* Execute the job.
*/
public function handle(): void
{
if(Storage::disk('s3')->exists($this->image->path) && Storage::disk('s3')->size($this->image->path) < 1024 * 1024 * 30){
$this->image->addMediaFromDisk( $this->image->path, 's3' )
->withResponsiveImages()
->withCustomProperties( [
'alt' => $this->image->alt,
'caption' => $this->image->description,
] )->toMediaCollection('images', 'ir');
}
}
}
If i dispatchSync that job everthing works as expected but if i dispatch it on the queue i get an Method addMediaNotFound err.
The image model implemnts the HasMedia and uses the InteractsWithMedia trait:
class Image extends Model implements HasMedia
{
use HasFactory, InteractsWithMedia;
protected $guarded = [];
protected $appends = [ 'path' ];
...
Is there any restirction if the app runs from the console?
Hi there, im using the latest versions of laravel and livewire.
I have an existing Image model and i want to move the images to the media library, so i wanted to dispatch a job foreach existing image like so:
If i dispatchSync that job everthing works as expected but if i dispatch it on the queue i get an Method addMediaNotFound err. The image model implemnts the HasMedia and uses the InteractsWithMedia trait:
Is there any restirction if the app runs from the console?