2021-12-22 17:32:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use App\Models\Gamme;
|
|
|
|
|
use App\Models\Product;
|
2022-05-12 16:03:40 +02:00
|
|
|
use App\Models\SeoDatum;
|
2022-01-25 16:39:00 +01:00
|
|
|
use Illuminate\Http\Request;
|
2021-12-22 17:32:05 +01:00
|
|
|
|
|
|
|
|
class ProductsController extends Controller
|
|
|
|
|
{
|
2022-01-07 17:29:55 +01:00
|
|
|
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
2021-12-22 17:32:05 +01:00
|
|
|
public function show(Gamme $gamme, Product $product)
|
|
|
|
|
{
|
2022-01-23 13:31:31 +01:00
|
|
|
//$product = Product::whereSlug($product->slug)->first();
|
|
|
|
|
//dd($product);
|
2022-05-12 16:03:40 +02:00
|
|
|
|
|
|
|
|
//make ghost seoDatum from the gamme
|
|
|
|
|
$seoDatum = new SeoDatum();
|
|
|
|
|
$seoDatum->title = $product->name;
|
|
|
|
|
$seoDatum->description = $product->description;
|
|
|
|
|
|
|
|
|
|
return view('front.product', compact('product', 'gamme', 'seoDatum'));
|
2021-12-22 17:32:05 +01:00
|
|
|
}
|
2022-01-25 16:39:00 +01:00
|
|
|
|
|
|
|
|
public function search(Request $request) {
|
|
|
|
|
$filter = $request->query('filter');
|
|
|
|
|
|
|
|
|
|
if (!empty($filter)) {
|
|
|
|
|
$products = Product::where('is_published', 1)
|
|
|
|
|
->where('name', 'like', '%' . $filter . '%')
|
|
|
|
|
->get();
|
|
|
|
|
//->paginate(12);
|
|
|
|
|
} else {
|
|
|
|
|
$products = Product::where('is_published', 1)
|
|
|
|
|
->get();
|
|
|
|
|
//->paginate(12);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$search_title = 'Recherche : ' . $filter;
|
|
|
|
|
|
|
|
|
|
return view('front.search', compact('products', 'search_title', 'filter'));
|
|
|
|
|
}
|
2021-12-22 17:32:05 +01:00
|
|
|
}
|