vendredi 28 juin 2019

image does not exist on this collection instance

I am trying to display multiple images from the row called image in products table from the database to the view, but am getting this error Property [image] does not exist on this collection instance., I have tried other solutions but they don't work.

Here are the codes

Controller

  public function store(Request $request) 
  { 

    $Input=$request->all();
    $image=array();
    if($files=$request->file('image')){
        foreach($files as $file){
            $name=$file->getClientOriginalName();
            $file->move('images',$name);
            $image[]=$name;

        }

    } 
   product::create(array_merge($Input,
   [
    'image' => json_encode($image),

    ])); 
    return redirect()->back(); 

    }

Blade view

     @foreach(json_decode($products->image, true) as $product)
      <img src="" alt="">
     @endforeach

Any help will be appriciated.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2YljZvW
via IFTTT

Aucun commentaire:

Enregistrer un commentaire