Try,
/*
SELECT brands.url_key,devices.* FROM brands
INNER JOIN devices ON devices.brand_id=brands.id
WHERE brands.url_key='samsung-mobile-phones'
*/
$result = DB::table('brands')
->join('devices', 'devices.brand_id', '=', 'brands.id')
->where('brands.url_key', 'samsung-mobile-phones' );
If you set up a relationship between brands and devices in the brands model then you should be able to do this,
$result = Brands::where('url_key', 'samsung-mobile-phones' )->with('devices');
// the return structure would be different than the other query
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community