Please, I have a function in my controller.
I want to query the stock table to select the list of product_id
and after select
, it should go to product table to display the NAME
of product to the 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 don't want product_id
to be displayed to the user but the product name.