2
votes

I'm creating a new website and have been using route::resource and have loved being able to do a route model binding.

Using route::controller though variables show as {one?}/{two?} etc...

Is it possible to use route model binding when using route::controller?

I.E.

class UserController extends Controller {
    public function getProfile(User $user)
    {
        return $user->toJson();
    }
}

and

Route::controller('user', 'UserController');

would result in the following route: /user/profile/{user}?

1

1 Answers

0
votes

You can use Route::model() for your Route::controller.

But you must bind all params if you need all of them. For example:

Route::model('one','App\User');
Route::model('two','App\User');

Be sure that your uri request is site.com/controller/method_name/param_1/param_n