Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to join two tables in laravel

use IlluminateSupportFacadesDB;
//in the following example we will join two tables
//a products table and categories table
$categoryProducts = Product::join('categories', 'categories.id', '=', 'products.category_id')
        ->select('products.*', 'categories.category_name')
        ->where('products.status', 1)
        ->get();
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #join #tables #laravel
ADD COMMENT
Topic
Name
1+6 =