我有以下代码
class FooBar
{
protected $delegate;
public function __construct( $delegate )
{
$this->delegate = $delegate;
}
}
App::bind('FooBar', function()
{
return new FooBar();
});
class HomeController extends BaseController
{
protected $fooBar;
public function __construct()
{
$this->fooBar = App::make('FooBar');
//HomeController needs to be injected in FooBar class
}
}
class PageController extends BaseController
{
protected $fooBar;
public function __construct()
{
$this->fooBar = App::make('FooBar');
// PageController needs to be injected in FooBar class
}
}
如何在 FooBar 类中注入 HomeController、PageController 作为委托?
使用上面的代码,我得到一个缺少的参数错误