Biscoff Frappe
Elite
How to use a table id to another table using laravel? Join tables?
join method on a query builder instance to perform a join. Here's an example:$users = DB::table('users')
->join('orders', 'users.id', '=', 'orders.user_id')
->select('users.*', 'orders.order_number')
->get();
users table with the orders table based on the id column in users and the user_id column in orders. We're also selecting all columns from the users table and the order_number column from the orders table.users and orders with the names of your tables, and changing the column names to match the ones in your database.