Laravel - Query Builder - Retrieving All Rows From A Table

You may use the table method provided by the DB facade to begin a query. The table method returns a fluent query builder instance for the given table, allowing you to chain more constraints onto the query and then finally retrieve the results of the query using the get method:

    
    get();
    
            return view('user.index', ['users' => $users]);
        }
    }
	

The get method returns an Illuminate\Support\Collection instance containing the results of the query where each result is an instance of the PHP stdClass object. You may access each column's value by accessing the column as a property of the object:

    
    use Illuminate\Support\Facades\DB;
    
    $users = DB::table('users')->get();
    
    foreach ($users as $user) {
        echo $user->name;
    }
	
Laravel collections provide a variety of extremely powerful methods for mapping and reducing data. For more information on Laravel collections, check out the collection documentation.