163 lines
5.3 KiB
PHP
163 lines
5.3 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Ads;
|
|
use App\Models\Articles;
|
|
use App\Models\BalancedMenus;
|
|
use App\Models\BreederPortrait;
|
|
use App\Models\ConsumptionTimes;
|
|
use App\Models\Engagement;
|
|
use App\Models\FaqQuestions;
|
|
use App\Models\HomeSliderPictures;
|
|
use App\Models\MeatTypes;
|
|
use App\Models\Moments;
|
|
use App\Models\NewsSliderPictures;
|
|
use App\Models\OCBBreeder;
|
|
use App\Models\OCBContent;
|
|
use App\Models\Products;
|
|
use App\Models\ProductSliderPictures;
|
|
use App\Models\Ranges;
|
|
use App\Models\Recipes;
|
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
class RouteServiceProvider extends ServiceProvider
|
|
{
|
|
|
|
/**
|
|
* This namespace is applied to your controller routes.
|
|
*
|
|
* In addition, it is set as the URL generator's root namespace.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $namespace = 'App\Http\Controllers';
|
|
|
|
/**
|
|
* The path to the "home" route for your application.
|
|
*
|
|
* @var string
|
|
*/
|
|
public const HOME = '/bo';
|
|
|
|
/**
|
|
* Define your route model bindings, pattern filters, etc.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
Route::bind('publishedArticle', function ($value) {
|
|
return Articles::where('id', $value)->orWhere('slug', $value)->where('status', true)->firstOrFail();
|
|
});
|
|
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 Ranges::where('id', $value)->orWhere('slug', $value)->firstOrFail();
|
|
});
|
|
Route::bind('moment', function ($value) {
|
|
return Moments::where('id', $value)->orWhere('slug', $value)->firstOrFail();
|
|
});
|
|
Route::bind('slugRange', function ($value) {
|
|
return Ranges::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('meattype', function ($value) {
|
|
return MeatTypes::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('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();
|
|
});
|
|
|
|
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'));
|
|
}
|
|
}
|