{{-- @php $categories = App\Models\Category::with(['products' => function ($query) { $query->where('status', 1) ->orderBy('id', 'DESC') ->where('language_id', 1) ->limit(9); }]) ->get(); @endphp A vast collection of titles for your spiritual growth and development LIBRARY @foreach ($categories as $key => $category) {{ $category->category_name }} @endforeach @foreach ($categories as $key => $category) @forelse ($category->products as $product) {{ $product->product_name }} @empty Products Coming Soon @endforelse @endforeach Explore Library - View All Products --}} @php /* $categories = App\Models\Category::with(['products' => function ($query) { $query->where('status', 1)->where('language_id', 1)->orderBy('id', 'DESC'); }])->get(); */ $categories = App\Models\Category::where('status', 1)->with(['products' => function ($query) { $query->where('status', 1)->orderBy('language_id', 'ASC')->orderBy('id', 'ASC')->limit(12); }])->get(); @endphp @foreach ($categories as $category) {{ $category->category_name}} @forelse ($category->products as $book) {{-- {{ $book->product_name }} --}} {{-- --}} @empty Products Coming Soon @endforelse @endforeach