43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers;
|
||
|
|
|
||
|
|
use App\Models\MeatTypes;
|
||
|
|
use App\Models\Moments;
|
||
|
|
use App\Models\Ranges;
|
||
|
|
use Illuminate\Support\Facades\Route;
|
||
|
|
|
||
|
|
class ProductsFrontController extends Controller
|
||
|
|
{
|
||
|
|
public function index() {
|
||
|
|
dd('Les produits');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function filter($slug) {
|
||
|
|
$type = explode('/', Route::getCurrentRoute()->uri)[1];
|
||
|
|
switch ($type) {
|
||
|
|
case 'gamme':
|
||
|
|
$range = Ranges::where([['slug', $slug], ['status', 1]])->first();
|
||
|
|
if (!$range)
|
||
|
|
abort(404);
|
||
|
|
dd('Gamme : ' . $range->name);
|
||
|
|
break;
|
||
|
|
case 'type-viande':
|
||
|
|
$meatType = MeatTypes::where([['name', ucfirst($slug)], ['status', 1]])->first();
|
||
|
|
if (!$meatType)
|
||
|
|
abort(404);
|
||
|
|
dd('Type de viande : ' . $meatType->name);
|
||
|
|
break;
|
||
|
|
case 'moment-conso':
|
||
|
|
$moment = Moments::where([['slug', $slug], ['status', 1]])->first();
|
||
|
|
if (!$moment)
|
||
|
|
abort(404);
|
||
|
|
dd('Moment consomation : ' . $moment->title);
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
abort(404);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|