db table insert laravel code example

Example 1: laravel insert

DB::table('users')->insert([
    'email' => '[email protected]',
    'votes' => 0
]);

Example 2: laravel not in query

DB::table(..)->select(..)->whereNotIn('book_price', [100,200])->get();

Example 3: laravel wher in

$users = DB::table('users')
                    ->whereIn('id', [1, 2, 3])
                    ->get();

Example 4: laravel 8 orderby

$flights = App\Models\Flight::where('active', 1)
               ->orderBy('name', 'desc')
               ->take(10)
               ->get();

Example 5: DB::table('users')->get();

DB::table('users')->where('name', Input::get('name'))->get();

Example 6: laravel having

$users = DB::table('users')
                ->groupBy('account_id')
                ->having('account_id', '>', 100)
                ->get();

Tags:

Html Example