with laravel query code example

Example 1: laravel sql query

use Illuminate\Support\Facades\DB;

$users = DB::select('select * from users');

foreach ($users as $user) {
    echo $user->name;
}

Example 2: laravel db query

$users = DB::table('users')
            ->where('votes', '>', 100)
            ->orWhere(function($query) {
                $query->where('name', 'Abigail')
                      ->where('votes', '>', 50);
            })
            ->get();

Example 3: Laravel query where and

Table::where('Column', Value)->where('NewColumn', Value)->get();

Example 4: laravel where

$users = DB::table('users')
                ->whereMonth('created_at', '12')
                ->get();

Example 5: laravel where

$users = DB::table('users')
                ->whereDate('created_at', '2016-12-31')
                ->get();

Tags:

Php Example