. */ namespace App\Providers; use Illuminate\Routing\Router; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Route; use App\Models\User; class RouteServiceProvider extends ServiceProvider { /** * This namespace is applied to the controller routes in your routes file. * * In addition, it is set as the URL generator's root namespace. * * @var string */ protected $namespace = 'App\Http\Controllers'; /** * Define your route model bindings, pattern filters, etc. * * @return void */ public function boot() { parent::boot(); Route::model('userId', User::class); Route::bind('userSlug', function ($value) { return User::where('slug', $value)->first(); }); } /** * Define the routes for the application. * * @return void */ public function map() { Route::group([ 'middleware' => 'web', 'namespace' => $this->namespace ], function ($router) { require base_path('routes/web.php'); }); } }