mercredi 6 juillet 2016

Need to change dynamically a dependency injected class in a Restfull Laravel Controller

I'm using Laravel 5 as a framework and I'm facing a problem right now with the type-hint based dependency injection:

I would like to reduce the quantity of {Model}CreateRequest and {ModelUpdateRequest}. To solve that I thought of creating a base BaseController with the common store, update create, destroy methods that other classes will inherit from. Classes like PageController, PostController, NewsController, etc. The problem is, default Laravel CRUD controllers have a built dependency injection in methods update and store (classes {Model}CreateRequest and {ModelUpdateRequest} are injected)

How could I dynamically change the class injected in the BaseController?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire