laravel get one column code example
Example 1: laravel get certain columns
ModelName::all('column1', 'column2', 'column3');
Example 2: eloquent all only one culomn
$collection = collect([
['product_id' => 'prod-100', 'name' => 'Desk'],
['product_id' => 'prod-200', 'name' => 'Chair'],
]);
$plucked = $collection->pluck('name');
$plucked->all();
Example 3: laravel get single column value
$items = DB::table('items')
->select('id', 'ref_code', 'name', 'price')
->where('ref_code','=', $request->ref_code)
->first();