아래 오류로 strugging했습니다. 인터페이스 오류가 아니라 모델 오류입니다. 나는 아래 코드에서 무엇이 잘못되었는지 알지 못한다.BindingResolutionException 대상 [Illuminate Database Eloquent Model]이 인스턴스화 가능하지 않습니다.
이 문제를 해결할 생각이 없습니다.
회사 모델이 있습니다.
namespace ohbt\Repositories\Eloquents;
use Company;
use Illuminate\Database\Eloquent\Model;
use ohnt\Services\Validator\CompanyValidator as Validator;
use ohbt\Repositories\CompanyRepositoryInterface as CompanyRepositoryInterface;
class CompanyRepository extends AbstractRepository implements CompanyRepositoryInterface{
protected $company;
protected $validator;
public function __constructor(Model $company, Validator $validator){
$this->company = $company;
parent::__construct($this->company);
$this->validator = $validator;
}
public function create(array $attributes){
if($this->validator->isValid($attributes)){
$this->company->create($attributes);
return true;
}
return false;
}
public function getMessages(){
return $this->validator->getMessages();
}
}
이 companyrepository입니다 companyrepositoryinterface
namespace ohbt\Repositories;
interface CompanyRepositoryInterface{
}
입니다 그리고 내 repositoryservices 공급자가 이미 응용 프로그램/설정/app.php
namespace ohbt\Repositories;
use Illuminate\Support\ServiceProvider;
class RepositoriesServiceProvider extends ServiceProvider {
protected $defer = false;
public function boot()
{
//
}
public function register()
{
$this->app->bind('VehicleRepositoryInterface', 'ohbt\Repositories\Eloquents\VehicleRepository');
$this->app->bind('UserRepositoryInterface', 'ohbt\Repositories\Eloquents\UserRepository');
$this->app->bind('CompanyRepositoryInterface', 'ohbt\Repositories\Eloquents\CompanyRepository');
}
public function provides()
{
return array();
}
}
정말 응용 프로그램에 추가
use Illuminate\Database\Eloquent\Model;
class Company extends Eloquent{
protected $softDelete = true;
protected $table = "companies";
protected $fillable = [];
protected $guarded = [];
}
어떤 제안이나 도움을 피하십시오. 고맙습니다.
이제 companyrepository에서 사용하는 회사 검사기 서비스에 문제가 있습니다. ' $ this-> validator-> isValid ($ 속성); ' "비 객체의 속성을 가져 오려고 시도 중"오류가 있습니다. 적절한 해결책을 찾으십시오. 이 인터페이스를 다른 인터페이스와 바인딩 할 수없는 이유는 무엇입니까? –
RepositoriesServiceProvider를 app.php의 providers 배열에 추가 했습니까? – billrichards