1/*
2|======================================================================================
3| Get Category With Its Products and Product's First Variant -- Selected Columns Only
4|======================================================================================
5*/
6$category_products = Category::select('id','title','banner_image')
7 ->where('id',$id)
8 ->with([
9 'products' => function($query) {
10 $query->select('id','name','primary_image','category_id');},
11 'products.firstVariant' => function($query) {
12 $query->select('id','retail_price','sale_price','product_id');
13 }
14 ])
15 ->first();
16