Support the ongoing development of Laravel.io →
Requests Eloquent Architecture

hello,

My L5 route bind is not working.

My controller is in another namespace. I tested the data exists in db.

http://laravel.io/bin/Lkkol

<?php namespace App\Providers;

//RouteServiceProvider

use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider {

	protected $namespace ='';//App\Http\Controllers';

	public function boot(Router $router)
	{
		parent::boot($router);

		$router->bind('profilename', function($value)
		{
		    return App\DbClass\UserProfiles::username($value)->active()->first();
		});
	}

	public function map(Router $router)
	{
		$router->group(['namespace' => $this->namespace], function($router)
		{
			require app_path('Http/routes.php');
		});
	}

}

?>

//Route

Route::get('/{profilename}',  'Web\ProfileController@profile');

// Controller 
<?php namespace App\Http\Controllers\Web;

use App\Http\Controllers\Controller;
use App\User, App\DbClass\UserProfiles;
class ProfileController extends Controller {

	public function profile(UserProfiles $profile)
	{
		dd($profile);
	}
}

Thank You

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

abelkbil abelkbil Joined 22 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.