需要在Restfull Laravel Controller中动态更改依赖注入类

时间:2016-07-06 14:10:42

标签: php dependency-injection laravel-5 type-hinting

我正在使用Laravel 5作为框架,我现在面临一个基于类型提示的依赖注入问题:

我想减少{Model} CreateRequest和{ModelUpdateRequest}的数量。为了解决这个问题,我想到了使用公共存储创建基本BaseController,更新create,destroy将继承其他类的方法。像PageController,PostController,NewsController等类。问题是,默认Laravel CRUD controllers在方法update和store(注入类{Model} CreateRequest和{ModelUpdateRequest})中有一个构建的依赖注入。

如何动态更改BaseController中注入的类?

0 个答案:

没有答案