DB::create laravel code example
Example 1: laravel create db table
php artisan make:migration create_users_table
Example 2: laravel db::query update
DB::table('user')->where('email', $userEmail)->update(array('member_type' => $plan));
Example 3: TRANSACTON LARAVEL QUERY BUILDER
DB::beginTransaction();
try {
DB::insert(...);
DB::commit();
} catch (\Throwable $e) {
DB::rollback();
throw $e;
}
Example 4: laravel 8 orderby
$flights = App\Models\Flight::where('active', 1)
->orderBy('name', 'desc')
->take(10)
->get();