<?php
namespace App\Http\Controllers;
use App\Models\ProductCategory;
use App\Models\Product;
use Artesaos\SEOTools\Facades\SEOTools;
class ProductController extends Controller {
public function index(string $lang) {
SEOTools::setTitle('Our Products | Chandra & Sons Pharma');
SEOTools::setDescription('Browse our complete range of branded medicines, generic medicines, surgical supplies, and OTC wellness products.');
return view('pages.products.index', ['lang' => $lang, 'categories' => ProductCategory::active()->get()]);
}
public function category(string $lang, string $slug) {
$category = ProductCategory::where('slug', $slug)->where('is_active', true)->firstOrFail();
$products = Product::where('category_id', $category->id)->where('is_active', true)->paginate(24);
SEOTools::setTitle($category->getTranslation('name', $lang) . ' | Chandra & Sons Pharma');
SEOTools::setDescription($category->getTranslation('description', $lang));
return view('pages.products.category', ['lang' => $lang, 'category' => $category, 'products' => $products]);
}
}