ldc-doux/app/Http/Controllers/ProductsController.php

45 lines
1.3 KiB
PHP
Raw Normal View History

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;
use Illuminate\Http\Request;
2021-12-22 17:32:05 +01:00
class ProductsController extends Controller
{
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
2021-12-22 17:32:05 +01:00
public function show(Gamme $gamme, Product $product)
{
//$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
}
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
}