Answers for "joins in laravel 8"

PHP
3

laravel join table

$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();
Posted by: Guest on April-29-2020
2

wherein laravel

DB::table('user')->whereIn('id', [100,200])->get();
Posted by: Guest on December-16-2020
3

join in laravel eloquent

$customer = DB::table('customers')
                ->join('shops', 'customers.shop_id', '=', 'shops.shop_id')
                ->where('customer_contact', $contact_no)
                ->get();
Posted by: Guest on October-06-2020
0

laravel joins

// example 1
User::joinRelationship('posts');

// example 2
User::joinRelationship('posts.comments');
Posted by: Guest on August-31-2021

Browse Popular Code Answers by Language