From the Laravel docs: Unions - http://laravel.com/docs/queries#unions
$first = DB::table('users')->whereNull('first_name');
$users = DB::table('users')->whereNull('last_name')->union($first)->get();
Obviously the query builder will have to be altered to match your SELECT and WHERE statements, but the UNION would be the same.
$second= DB::table('brands') ->select('brand_id') ->where('parent_id','=',$id); $first = DB::table('goods') ->select('goods_id', 'name', 'img', 'anons', 'price', 'hits', 'new', 'sale') ->where('visible','=','1') ->whereIn('goods_brandid', [$second]); $products =DB::table('goods') ->select('goods_id', 'name', 'img', 'anons', 'price', 'hits', 'new', 'sale') ->where('goods_brandid', '=', $id) ->where('visible','=','1') ->union($first)->get();
is it right?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community