so this is my route.php
Route::get('tempitems/{tempId}/add/{q?}',
['uses' => 'ItemTemplateController@addItems', 'as' => 'tempitems.add']);
this is the addItems method
public function addItems(Request $request, $tempId)
{
echo ($tempId) // 1 st echo
$temp = DB::table('auto_items')
->join('items', 'auto_items.item_id', '=', 'items.id')
->select(
'items.name',
'auto_items.qty'
)
->where('auto_items.template_id', '=' , 1)
->tosql();
dd($temp);
echo $tempId; // 2nd echo
return view('template_items.add_items', [
'active' => $this->active,
'items' => $items,
'template' => $template,
'page' => $page,
'success' => $success,
'tempItems' => $tempItems
]);
}
the problem is the query builder cannot read the $tempId when i accessed : localhost:8000/tempitems/1/add
1st echo => return 1
dd return =>
"select `items`.`name`, `auto_items`.`qty` from `auto_items` inner join `items` on
`auto_items`.`item_id` = `items`.`id` where `auto_items`.`template_id` = ?"
2nd echo returned 1
by the way, i know that Query Builder use get() to return rows, because of it returned zero array / [ ] , thats why im using toSql(). but the point is the $tempId cannot be read by the QueryBuilder.
Any help is appreciated thanks .
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire