where('id', $value)->orWhere('slug', $value); })->where('status', true)->firstOrFail(); }); Route::bind('publishedActu', function ($value) { return Actu::where(function ($q) use ($value) { $q->where('id', $value)->orWhere('slug', $value); })->where('status', true)->firstOrFail(); }); Route::bind('articleTag', function ($value) { try { return ArticleCategory::make($value); } catch (BadMethodCallException | EnumNotRoutableException $e) { // handle old article route $publishedArticle = Articles::where('id', $value) ->orWhere('slug', $value)->where('status', true)->first(); if ($publishedArticle) { // redirect permanent, throw redirect exception using send method \redirect(route('club.infos.child', [ 'articleTag' => $publishedArticle->type, 'publishedArticle' => $publishedArticle ]), 301)->send(); } else { abort(404); } } }); Route::bind('engagement', function ($value) { return Engagement::where('id', $value)->firstOrFail(); }); Route::bind('product', function ($value) { return Products::where('id', $value)->orWhere('slug', $value)->firstOrFail(); }); Route::bind('range', function ($value) { return Range::where('id', $value)->orWhere('slug', $value)->firstOrFail(); }); Route::bind('moment', function ($value) { return Moments::where('id', $value)->orWhere('slug', $value)->firstOrFail(); }); Route::bind('subRange', function ($value) { return SubRange::where('id', $value)->orWhere('slug', $value)->firstOrFail(); }); Route::bind('slugRange', function ($value) { return Range::where('slug', $value)->where('status', true)->firstOrFail(); }); Route::bind('slugConsumptionTime', function ($value) { return ConsumptionTimes::where('slug', $value)->where('status', true)->firstOrFail(); }); Route::bind('slugMeatType', function ($value) { return MeatTypes::where('slug', $value)->where('status', true)->firstOrFail(); }); Route::bind('consumptiontime', function ($value) { return ConsumptionTimes::where('id', $value)->orWhere('slug', $value)->firstOrFail(); }); Route::bind('meat_type', function ($value) { return MeatTypes::where('id', $value)->orWhere('slug', $value)->firstOrFail(); }); Route::bind('ocbbreeder', function ($value) { return OCBBreeder::where('id', $value)->orWhere('slug', $value)->firstOrFail(); }); Route::bind('ad', function ($value) { return Ads::where('id', $value)->firstOrFail(); }); Route::bind('homeslider', function ($value) { return HomeSliderPictures::where('id', $value)->firstOrFail(); }); Route::bind('newsslider', function ($value) { return NewsSliderPictures::where('id', $value)->firstOrFail(); }); Route::bind('productslider', function ($value) { return ProductSliderPictures::where('id', $value)->firstOrFail(); }); Route::bind('recipe', function ($value) { return Recipes::where('id', $value)->orWhere('slug', $value)->firstOrFail(); }); Route::bind('balanced_menu', function ($value) { return BalancedMenus::where('id', $value)->firstOrFail(); }); Route::bind('actu', function ($value) { return Actu::where('id', $value)->orWhere('slug', $value)->firstOrFail(); }); Route::bind('article', function ($value) { return Articles::where('id', $value)->orWhere('slug', $value)->firstOrFail(); }); Route::bind('faq_question', function ($value) { return FaqQuestions::where('id', $value)->firstOrFail(); }); Route::bind('breederportrait', function ($value) { return BreederPortrait::where('id', $value)->firstOrFail(); }); Route::bind('ocb', function ($value) { return OCBContent::where('id', $value)->firstOrFail(); }); Route::model('tag', Tag::class); Route::bind('general_config', function ($value) { try { $value = \ctype_digit($value) ? \intval($value) : $value; foreach (GeneralConfigType::toArray() as $config) { if ($config->value === $value) { return GeneralConfig::where('type', $value)->firstOrFail(); } } abort(404); } catch (BadMethodCallException | EnumNotRoutableException $e) { return null; } }); parent::boot(); } /** * Define the routes for the application. * * @return void */ public function map() { $this->mapApiRoutes(); $this->mapWebRoutes(); // } /** * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. * * @return void */ protected function mapWebRoutes() { Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); } /** * Define the "api" routes for the application. * * These routes are typically stateless. * * @return void */ protected function mapApiRoutes() { Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); } }