I have a table products
:
Products
-id
-seller_id
-category_id
-product_name
and also a Product_options
table:
Product_options
-id
-product_id
-size_name
-width
-height
-quantity
-price
I have here a function show
which is a function where you can view the products in home.blade.php:
public function show($id)
{
$likes = DB::SELECT(DB::RAW("SELECT count(*) as like_count FROM `likes` WHERE product_id = $id"));
$products = DB::SELECT(DB::RAW("SELECT p.id as product_id, p.name as product_name, p.price, p.description, p.image, c.id as category_id, c.name as category_name FROM products p, categories c WHERE p.category_id = c.id AND p.id = $id"));
$product_options = DB::SELECT(DB::RAW("SELECT po.pricee FROM product_options po, products p WHERE p.id = po.product_id AND product_id = $product_id "));
return View::make('products.show', ['products' => $products, 'like_count' => $likes[0]->like_count,'product_options'=>$product_options]);
Home.blade.php
if(isset($products) && $products) {
foreach ($products as $product => $value) {
$new_description = strlen($products[$product]->description) > 50 ? substr($products[$product]->description,0,50)."..." : $products[$product]->description;
echo '
<div class="col-sm-6 col-md-4">
<div class="thumbnail" >
<div class="pull-right">';
if(Auth::check()) {
if(Auth::user()->id == $products[$product]->seller_id) {
echo '<a href="'.URL::to('product/editproduct', [$products[$product]->product_id]).'">
<span class="glyphicon glyphicon-edit"></span>
</a>';
}
else {
echo '<a href=""> </a>';
}
}
echo '</div><a href="'.URL::route('categories', [$products[$product]->category_name]).'"><h4 class="text-center"><span class="label label-info">'.$products[$product]->category_name.'</span></h4></a>
<div class="img-container-background">
<div class="img-container">
<a href="'.URL::to('product/'.$products[$product]->product_id).'"> <img src="'.URL::asset('assets/images/uploads/'.$products[$product]->image).'" class="img-responsive" /></a>
</div>
</div>
<div class="caption">
<div class="row">
<div class="col-md-6 col-xs-6">
<h3 style="font-size:20px">'.$products[$product]->product_name.'</h3>
<span>By <a href="">'.$products[$product]->seller_name.'</a></span>
How I can get the price of product_options
to view the price in my home blade?