File: /home/armgroup/libs/app/Http/Controllers/Frontend/ProductCategoryController.php
<?php
namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\Product;
class ProductCategoryController extends Controller
{
public function __invoke($slug)
{
if ($product = Product::query()->where('slug', $slug)->first()) {
return (new ProductController)->show($product);
}
$category = Category::query()->where('slug', $slug)->firstOrFail();
return (new SearchController)->category($category);
}
}