Trying to access array offset on value of type null
Hi everyone,
I am trying to migrate data from the old site to the new site. When I try to upload images from the old site to the new site. It will give me a "Trying to access array offset on value of type null" error. Anyone can help me to resolve this error.?
Here is my controller method"
public function imageMigration()
{
$images = DB::connection('aegis_tech')->table('entity_files')->where('entity_type', '=','Modules\Product\Entities\Product')->get();
foreach ($images as $image)
{
DB::beginTransaction();
$file = DB::connection('aegis_tech')->table('files')->where('id', '=', $image->file_id)->get()->toArray();
$product = Product::find($image->entity_id);
$product->addMediaFromUrl('http://www.aegiztech.com/newsite/public/storage/'.$file[0]->path)
->withResponsiveImages()
->toMediaCollection('product');
DB::commit();
}
return "All Images are transferred.";
}
@Sinnbeck you're right. It's most likely unrelated to the given code. Because even in his original code, I don't see how he could have gotten that error. "Undefined offset" would have been possible, but "Trying to access array offset on value of type null" not so much, because the only array access I can see in his code is on an array.
@Sinnbeck You guys are correct this error is not related to my code. Here is the screenshot of the code. https://prnt.sc/26iyksi I do not have any idea about where I am wrong. I am trying to upload images from URL using Spatie Laravel-medialibrary v8