hello,
My L5 route bind is not working.
My controller is in another namespace. I tested the data exists in db.
<?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
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community