mardi 17 juillet 2018

How to get category according product from database using chunk() with collection in laravel 5.6

Can anyone help me with this solution? I try to get data according to the category using the chunk method and also I use a collection. But when I use Where clause in a collection then it gives me null value. please help me.

$products=DB::table('stock_management')
->join('warehouse_products','stock_management.product_id','=','warehouse_products.id')
->leftjoin('brand','warehouse_products.brand_id','=','brand.id')
->select('warehouse_products.*','brand.name as Brandname','brand.remember_token as color')
->orderBy('brand.name','ASC')
->get()
->chunk(50);

$collection=collect($products);
$getProduct=$collection->where('categories_id','=',34);
$catProduct=$getProduct->all();
dd($catProduct);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire