Okay so after spending a day on this and wrecking my head, I went by using a DB:
public function storeHeroImage(Request $request) {
if ($request->hasFile('image')) {
// Delete the old photo
$oldImg = DB::select('select * from hero_images ORDER BY id DESC LIMIT 1');
Storage::disk('public')->delete('hero-images/' . $oldImg[0]->imgName);
$imgName = time() . '-hero.png';
$imgResize = Image::make($request->image->getRealPath());
$imgResize = $imgResize->resize(1400, null, function ($constraint) {
$constraint->aspectRatio();
});
// Insert into DB
DB::insert('insert into hero_images (imgName) values (?)', [$imgName]);
$imgResize->save(storage_path() . '/app/public/hero-images/' . $imgName);
}
return back();
}
and read i in my Blade component:
<img src="{{ asset('storage/hero-images/' . DB::select('select * from hero_images ORDER BY id DESC LIMIT 1')[0]->imgName) }}">
Of course if you were to use it make sure have the rights checks in place. Thank you 👨💻