FleetCart/Modules/Brand/Http/Controllers/BrandProductController.php
2023-12-03 14:07:47 +00:00

40 lines
989 B
PHP

<?php
namespace Modules\Brand\Http\Controllers;
use Illuminate\Http\Response;
use Modules\Brand\Entities\Brand;
use Modules\Product\Entities\Product;
use Modules\Product\Filters\ProductFilter;
use Modules\Product\Http\Controllers\ProductSearch;
class BrandProductController
{
use ProductSearch;
/**
* Display a listing of the resource.
*
* @param string $slug
* @param Product $model
* @param ProductFilter $productFilter
*
* @return Response
*/
public function index($slug, Product $model, ProductFilter $productFilter)
{
request()->merge(['brand' => $slug]);
if (request()->expectsJson()) {
return $this->searchProducts($model, $productFilter);
}
$brand = Brand::findBySlug($slug);
return view('public.products.index', [
'brandName' => $brand->name,
'brandBanner' => $brand->banner->path,
]);
}
}