Laravel 4Ways to Select specific columns
JohnDivam

JohnDivam @johndivam

About: Focus on delivering high-quality solutions. #Laravel . Wye Team

Joined:
Jul 11, 2023

Laravel 4Ways to Select specific columns

Publish Date: Sep 18 '23
2 0

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']);
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment