我有一个锋模型称为表面这取决于一个ZipCodeRepository对象上:Laravel5依赖注入上模型
class Surface extends Model{
public function __construct(ZipCodeRepositoryInterface $zipCode){...}
和一个地址对象的hasMany表面。
class Address extends Model{
public surfaces() { return $this->hasMany('App/Surface'); }
}
我的问题是,当我打电话$address->surfaces
我得到以下错误:
Argument 1 passed to App\Surface::__construct() must be an instance of App\Repositories\ZipCodeRepositoryInterface, none given
我认为国际奥委会将自动注入这一点。
看这里:https://stackoverflow.com/questions/22338161/cant-pass-class-instance-to-constructor/22338753 ...特别是在github上打开的问题 – svrnm