I'm trying to speed up image uploads using queues on Livewire and I'm getting the following error:
Serialization of 'Livewire\TemporaryUploadedFile' is not allowed
My code:
foreach($this->imagenes as $imagen){
ProcesarImagenes::dispatch($imagen, $propiedadId);
}
Job:
protected $imagen;
protected $propiedadId;
public function __construct($imagen, $propiedadId)
{
$this->imagen = $imagen;
$this->propiedadId = $propiedadId;
}
public function handle()
{
$imagen = $this->imagen;
$propiedadId = $this->propiedadId;
$nombre = Str::random(10) . $imagen->getClientOriginalName();
$ruta = public_path() . '\imagenesPropiedades/' . $nombre;
//make recibe la imagen
Image::make($imagen)
->resize(800, null, function ($constraint) {
$constraint->aspectRatio();
})
->save($ruta);
$img = imgPropiedades::create([
'url' => '/imagenesPropiedades/' . $nombre,
'property_id' => $this->propiedadId
]);
}
I appreciate if you can help me if it is possible to use Queues in Livewire .
Thank you very much.
The problem was the serialization since it expects a class, so I converted it to an array and it works perfectly.