38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Gamme;
|
|
use App\Models\Product;
|
|
use App\Models\SeoDatum;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ProductsController extends Controller
|
|
{
|
|
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
|
public function show(Gamme $gamme, Product $product)
|
|
{
|
|
$seoDatum = new SeoDatum();
|
|
$seoDatum->title = $product->name;
|
|
$seoDatum->description = $product->description;
|
|
|
|
return view('front.product', compact('product', 'gamme', 'seoDatum'));
|
|
}
|
|
|
|
public function search(Request $request) {
|
|
$filter = $request->query('filter');
|
|
|
|
if (!empty($filter)) {
|
|
$products = Product::where('is_published', 1)
|
|
->where('name', 'like', '%' . $filter . '%')
|
|
->get();
|
|
} else {
|
|
$products = Product::where('is_published', 1)
|
|
->get();
|
|
}
|
|
|
|
$search_title = 'Recherche : ' . $filter;
|
|
|
|
return view('front.search', compact('products', 'search_title', 'filter'));
|
|
}
|
|
}
|