laravel model get column value code example
Example 1: laravel eloquent get column
Model::where('id', 1)->get(['column1','column2']);
or
Model::all(['column1']);
Model::whereNull('deleted_at')->pluck('column1');
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();