select specific columns from a database table using various methods provided by the Eloquent ORM (Object-Relational Mapping). Here are four common ways to select specific columns on a model:
$users = User::select('id', 'name')->get();
// or
$users = User::select(['id', 'name'])->get();
// or
$users = User::find(3,['id', 'name']);
// or
$users = User::get(['id', 'name']);
Top comments (0)