Current File : /home/tradevaly/www/app/Http/Controllers/Frontend/FrontendController.php
<?php

namespace App\Http\Controllers\Frontend;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Category;
use App\Models\Product;
use App\Models\Cwp;
use App\Models\CategoryWiseProduct;

class FrontendController extends Controller
{
    public function category_details($id){
        $cwp['cwp'] = Cwp::findOrFail($id);
        $category_id = $cwp['cwp']->category_id;
        $data['category'] = Category::findOrFail($category_id);
        $data['subcategories'] = Category::where('parent_id',$category_id)->latest()->get();
        $data['products'] = CategoryWiseProduct::where('cwp_id',$id)->latest()->get()->take(24);
        
        return view('frontend.pages.category.details')->with($data);
    }
}