laravel get value from database code example

Example 1: How to request and display data from db in larave

$users = DB::table('users')->get();
foreach($users as $key => $value)
{
	//to get each columns value
	//$value->name
}

Example 2: get single column value in laravel eloquent

Vehicle::find(3)->value('register_number');

Example 3: laravel select count

$count = DB::table('category_issue')->count();

Example 4: laravel find query

$model = App\Models\Flight::where('legs', '>', 100)
            ->firstOr(['id', 'legs'], function () {
                // ...
            });

Tags:

Php Example