In my controller's method I call my service to store images.
MediaService::storeImages($pa, $r->images, $r->main_image);
FileService.php
public static function storeImages($pa, $images, $mainImageName)
{
dd(1, $mainImage);
MediaService::addMediaToCollection($pa, $mainImage);
}
public static function addMediaToCollection($model, &$medium, $collection = null)
{
dd(2, $medium);
}
First dump and die looks like this:
But the second one turns into this, losing its attributes: 
I tried adding and removing & to accept the pointer instead of copy but it didn't help.
I know I could create instance of this class and have the image as a variable accessible by all the methods, but its beyond my question, which is - why this occurs and how to stop it?
Thank you.
source https://stackoverflow.com/questions/76794645/laravels-uploaded-file-loses-properties-while-passing-between-methods

No comments:
Post a Comment