关于 l5-repository
不知道大家有没有用 l5-repository 的。我之前用 symfony,所以习惯了又 repository 这一层,看网上有人推荐 l5-repository,但是我在用过的过程发现,repository 只能在 controller 中依赖注入使用?
class PostsController extends BaseController {
protected $repository;
public function construct(PostRepository $repository){
$this->repository = $repository;
}
}
不能直接 new 吗,而且如果一个 controller 中用到两个 repository 怎么办呢?
在直接 new 的时候报如下错误:
ErrorException in BaseRepository.php line 87:
Argument 1 passed to Prettus\Repository\Eloquent\BaseRepository::construct() must be an instance of Illuminate\Container\Container, none given, called in laravel52/app/Http/Controllers/HomeController.php on line 38 and defined
望用过的高手解答一下。
推荐文章: