Fix refresh sitemap
This commit is contained in:
parent
9221d331dc
commit
2e2df92132
4 changed files with 21 additions and 7 deletions
|
|
@ -30,7 +30,7 @@ class ProductsController extends Controller
|
|||
return view('front.products.index', compact('productsSlides', 'ranges', 'meatTypes', 'ct', 'labels'));
|
||||
}
|
||||
|
||||
public function filter(Model $model, SubRange $subrange = null)
|
||||
public function filter(Model $model, SubRange $slugSubRange = null)
|
||||
{
|
||||
// On récupère les mêmes données qu'au dessus pour l'affichage
|
||||
$productsSlides = ProductSliderPictures::where('status', 1)->orderBy('order', 'ASC')->get();
|
||||
|
|
@ -52,11 +52,11 @@ class ProductsController extends Controller
|
|||
/** @var \App\Models\Range */
|
||||
$gamme = $model;
|
||||
$subranges = $gamme->subranges()->orderBy('order')->get();
|
||||
if ($subrange) {
|
||||
if ($slugSubRange) {
|
||||
$title = $gamme->name;
|
||||
$productsList = $gamme->products()
|
||||
->where('status', true)
|
||||
->where('sub_range_id', $subrange->id)
|
||||
->where('sub_range_id', $slugSubRange->id)
|
||||
->orderBy('order')
|
||||
->get();
|
||||
} else {
|
||||
|
|
@ -88,7 +88,9 @@ class ProductsController extends Controller
|
|||
default:
|
||||
abort(404);
|
||||
break;
|
||||
}//end switch
|
||||
} //end switch
|
||||
|
||||
$subrange = $slugSubRange;
|
||||
|
||||
return view('front.products.index', compact(
|
||||
'productsList',
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ use App\Models\Reduction;
|
|||
use App\Models\SubRange;
|
||||
use App\Models\Tag;
|
||||
use BadMethodCallException;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Routing\Route as RoutingRoute;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Kwaadpepper\Enum\Exceptions\EnumNotRoutableException;
|
||||
|
||||
|
|
@ -108,8 +110,16 @@ class RouteServiceProvider extends ServiceProvider
|
|||
Route::bind('moment', function ($value) {
|
||||
return Moments::where('id', $value)->orWhere('slug', $value)->firstOrFail();
|
||||
});
|
||||
Route::bind('slugSubRange', function ($value, RoutingRoute $route) {
|
||||
// * slugRange must be resolved since slugSubRange comes second on url.
|
||||
/** @var \App\Models\Range */
|
||||
$slugRange = $route->parameter('slugRange');
|
||||
return SubRange::whereSlug($value)->whereHas('ranges', function (Builder $q) use ($slugRange) {
|
||||
$q->where('id', $slugRange->id);
|
||||
})->firstOrFail();
|
||||
});
|
||||
Route::bind('subRange', function ($value) {
|
||||
return SubRange::where('id', $value)->orWhere('slug', $value)->firstOrFail();
|
||||
return SubRange::where('id', $value)->firstOrFail();
|
||||
});
|
||||
Route::bind('slugRange', function ($value) {
|
||||
return Range::where('slug', $value)->where('status', true)->firstOrFail();
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ $vegetal = ($vegetal || isset($gamme) && $gamme && $gamme->slug === "le-vegetal"
|
|||
@svg('assets/images/produit/arrow-_-.svg')
|
||||
</a>
|
||||
@foreach($subranges as $srange)
|
||||
<a class="subrangefilter noselect @if($subrange and $srange->id === $subrange->id)active @endif" href="{{ route('products.range', ['slugRange' => $gamme->slug, 'subRange' => $srange->slug]) }}">
|
||||
<a class="subrangefilter noselect @if($subrange and $srange->id === $subrange->id)active @endif" href="{{ route('products.range', ['slugRange' => $gamme->slug, 'slugSubRange' => $srange->slug]) }}">
|
||||
@if(isset($srange->picture) and strlen($srange->picture))
|
||||
<picture>
|
||||
<source srcset="{{ asset(resizePublic($srange->picture, 'productFilterWEBP')) }}" type="image/webp">
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@ Route::prefix('/produits')
|
|||
->name('products.')
|
||||
->group(function () {
|
||||
Route::get('/', [ProductsController::class, 'index'])->name('index');
|
||||
Route::get('/gamme/{slugRange}/{subRange?}', [ProductsController::class, 'filter'])->name('range');
|
||||
Route::get('/gamme/{slugRange:slug}/{slugSubRange:slug?}', [
|
||||
ProductsController::class, 'filter'
|
||||
])->name('range');
|
||||
Route::get('/moment-consommations/{slugConsumptionTime}', [ProductsController::class, 'filter'])
|
||||
->name('consumption-times');
|
||||
Route::get('/type-viande/{slugMeatType}', [ProductsController::class, 'filter'])->name('meat-type');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue