Answers for "eloquest how to select one specific column in database"

1

laravel eloquent get only field name

//Eloquent: Get specific columns (not all the row). Pluck returns an array.
Model::where('id', 1)->pluck('name', 'surname');
// If you only want to get the result value:
Model::where('id', 1)->value('name');
Posted by: Guest on May-17-2020
0

eloquest how to select one specific column in database

$result = DB::Table('table_name')->select('column1','column2')->where('id',1)->get();
Posted by: Guest on June-10-2020
1

eloquest how to select one specific column in database

Model::where('id', 1)
         ->pluck('name', 'surname')
         ->all();
Posted by: Guest on June-10-2020
0

eloquest how to select one specific column in database

ModelName::where('a', 1)->get(['column1','column2']);
Posted by: Guest on June-10-2020
0

eloquest how to select one specific column in database

ModelName::find($id, ['name', 'surname']);
Posted by: Guest on June-10-2020

Code answers related to "eloquest how to select one specific column in database"

Browse Popular Code Answers by Language