Please I have a function in my controller. I want to query stock table to select the list of product_id and atfer select, it should go to product table to display the NAME of product to user instead of product_id.
public function getStockList()
{
$stock = DB::table("stocks")->pluck("product_id","product_id")->all();
**$products = DB::table("products")->pluck("name")->where('id', $stock);**
return view('shop.shop')->with(['stocks' => $stocks,
'stock' => $stock, 'products' => $products]);
}
My php blade has
{!! Form::select('stock', ['' => 'Select'] +$stock,'',array('class'=>'form-control','id'=>'country','style'=>'width:350px;'))!!}
{!! Form::select('product_id', [''=>'Select Supplier'] + $products, null, ['class'=>'form-control'])!!}
Basically, I dont want product_id to be display to user but the product name.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2vBBl97
via IFTTT
Aucun commentaire:
Enregistrer un commentaire