How can you be sure that book is found? http://laravel.com/api/5.1/Illuminate/Database/Eloquent/Builder.html#method_find
The find method will return null if it's not found. Why don't you try the findOrFail method? You can confirm if the object is found by putting
dd($book);
after the find.
When I dd($content); I get the two books that i added to my cart, but I cannot get them to show up in my cart.blade.php. maybe my cart.blade.php is wrong?
this is the dd($content); output
CartCollection {#170 ▼
#items: array:2 [▼
"027c91341fd5cf4d2579b49c4b6a90da" => CartRowCollection {#171 ▼
#associatedModel: null
#associatedModelNamespace: null
#items: array:7 [▼
"rowid" => "027c91341fd5cf4d2579b49c4b6a90da"
"id" => 1
"name" => "PHP is fun"
"qty" => 9
"price" => 3.51
"options" => CartRowOptionsCollection {#172 ▶}
"subtotal" => 31.59
]
}
"370d08585360f5c568b18d1f2e4ca1df" => CartRowCollection {#173 ▼
#associatedModel: null
#associatedModelNamespace: null
#items: array:7 [▼
"rowid" => "370d08585360f5c568b18d1f2e4ca1df"
"id" => 2
"name" => "Welcome to Cisco"
"qty" => 75
"price" => 354.59
"options" => CartRowOptionsCollection {#174 ▶}
"subtotal" => 26594.25
]
}
]
}
This is my cart.blade.php code
<!DOCTYPE html>
<html>
<head>
<title>Cart Page</title>
</head>
<div>
<div>
<p>
<table>
<thead>
<tr>
<th>Book</th>
<th>Qty</th>
<th>Item Price</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $items->id;?></td>
<td><p><strong><?php echo $items->name;?></strong></p></td>
<td><input type="text" value="<?php echo $items->qty;?>"></td>
<td>$<?php echo $items->price;?></td>
</tr>
</tbody>
</table>
</p>
</div>
</div>
</body>
</html>
$cart isn't been given a value if you use compact('content').
you also need to loop through the items?
you havent given us the controller code for displaying cart? in the controller you could probably try to do dd($rowsfromdb) to check...
also check if CART table (I assume?) is populated..
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.