mardi 21 janvier 2020

Trying to get property of non-object I cant pass data on a productdetails view

i have an error on my code of Productdetails View Trying to get property 'name' of non-object

my web.php file

Route::delete('/Destroy/{id}','ProductsController@destroy');
Route::get('/Edit/{id}', 'ProductsController@edit');
Route::post('/Update/{id}','ProductsController@update');

Route::get('/listing',function(){

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

});

Route::get('Product-details/{id}','ProductsController@ProductDetail');

**

ProductDetail Funcion On controller

**

public function ProductDetail($id)
    {


        $products = Product::findOrFail($id);
        return View('pages.productdetails', compact('products',$products));
    }

and view

@foreach($products as $product)
<h1></h1>
@endforeach

And i have a problem in my view in data attributes

Mydatabase attributes

name, price, category, description,

platform.

i need to pass these data on product details view



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire