laravel where db raw code example

Example 1: laravel join

$users = DB::table('users')
            ->join('contacts', 'users.id', '=', 'contacts.user_id')
            ->join('orders', 'users.id', '=', 'orders.user_id')
            ->select('users.*', 'contacts.phone', 'orders.price')
            ->get();

Example 2: raw queries in laravel

DB::statement('UPDATE users SET role_id = 1 WHERE role_id IS NULL AND YEAR(created_at) > 2020');

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

$users = DB::table('users')->get();

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

DB::select('SELECT * FROM users WHERE name = ?', array(Input::get('name')));

Tags:

Html Example