$users = DB::table('users')->get(); foreach ($users as $user) { echo $user->name; }
$users = DB::table('users') ->where('name', 'John') ->get();In this example, we are fetching all the data from the users table where the name is John using the where method. We are then using the get method to retrieve the data. Package library: Laravel Eloquent ORM.