php - How can I get the price of the other table -


i have table products:

products -id -seller_id -category_id -product_name 

and product_options table:

product_options  -id -product_id -size_name -width -height -quantity -price 

i have here function show function can view products in home.blade.php:

public function show($id) {       $likes = db::select(db::raw("select count(*) like_count `likes` product_id = $id"));      $products = db::select(db::raw("select p.id product_id, p.name product_name, p.price, p.description, p.image, c.id category_id, c.name category_name products p, categories c p.category_id = c.id , p.id = $id"));      $product_options = db::select(db::raw("select po.pricee product_options po, products p p.id = po.product_id , 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 $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="">&nbsp;</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 can price of product_options view price in home blade?

i'd in controller:

$products = db::table('products') ->join('product_options', 'products.id', '=', 'product_options.product_id') ->get();  return view::make('products.show')     ->withproducts($products); 

let query builder hard work instead of writing out of queries, have loop through $products variable in home blade , should set.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -