mardi 19 juillet 2016

Polymorphic Route Model Binding on Laravel?

is there any way of creating a Polymorphic-like model implicitly binding on laravel 5.* ??

for example:

route('project.comment.store', $project->commentable)

register the route like this

Route::get('comments/{commentable}/store', ....controller . '@store')

and receive the exactly model on the controller store() method?

im guessing the only way i could archive this is if i modify the route to something like this

Route::get('comments/{commentable_type}/{commentable_id}/store', ....controller . '@store')

which looks a big ugly.. but works... any idea if is there any short and smarter way of doing so?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire