lundi 20 janvier 2020

Undefined variable: products (View: E:\Laravel Projects\laravelstore\resources\views\pages\productsdash.blade.php)

**I have a problem with the products View **

Code is in productsdash.blade.php

**

@if (count($products) > 0)
         @foreach ($products as $product)
      <tr>
        <th scope="row">1</th>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      @endforeach
      @else
      <div class="alert alert-danger" role="alert">
          No Products Found
        </div>
      @endif

**

controller Store Method public function index() {

    $products=Product::all();
       return view('pages.productsdash',compact('products'));

} 

controller Store Method

public function store(Request $request){

    $product=new Product();
    $product->name=$request->input('name');
    $product->category=$request->input('category');
    $product->condition=$request->input('condition');
    $product->price=$request->input('price');
    $product->platform=$request->input('platform');
    $product->description=$request->input('description');
    $product->save();
    return redirect('/Products')->with('success','Product Added');

}

I don't know what is a problem on my problem



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire