I have a table named "items" and an input for the where condition named "ref_code".
$items = DB::table('items')
->where('ref_code','=', $request->ref_code)
->get(['id', 'ref_code', 'name','price']);
But I can't seem to take the values of each column.
I checked wether the query builder worked or not by using:
return $items;
Fortunately, there's no problem.
But returning or getting a single value doesn't work with:
return $items->id
Is my syntax wrong? All of this are inside my controller.
EDIT: I tried
dd($items);
before returning and it showed me this:
Collection {#325 ▼
#items: array:1 [▼
0 => {#322 ▶}
]
}
$itemswould be a collection, hence you would need to loop through$itemsto get its propertiesdd($items)and update question with the result