You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
This discussion was converted from issue #3555 on March 08, 2024 15:11.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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?
Beta Was this translation helpful? Give feedback.
All reactions