Php 依赖注入变量模型

Php 依赖注入变量模型,php,laravel,dependency-injection,laravel-5,dependencies,Php,Laravel,Dependency Injection,Laravel 5,Dependencies,我有一堆扩展的抽象基本存储库 我如何让存储库将baseRepository的代码(Model::find($id);)与它们自己的模型一起使用?我尝试过使用self::setModel(新模型)但是当我调用find()时,我得到一个错误,说Model不是对象 我现在如何得到它: BaseRepository <?php /* * To change this license header, choose License Headers in Project Properties

我有一堆
扩展的
抽象基本存储库

我如何让存储库将baseRepository的代码(
Model::find($id);
)与它们自己的模型一起使用?我尝试过使用
self::setModel(新模型)
但是当我调用
find()
时,我得到一个错误,说
Model
不是
对象

我现在如何得到它:
BaseRepository

    <?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace App\Repositories;

use Illuminate\Container\Container;
/**
 * Description of BaseRepository
 *
 * @author Jordy
 */
abstract class BaseRepository implements RepositoryInterface {
  protected $model;

  function getModel() {
    return $this->model;
  }

  function setModel($model) {
    $this->model = $model;
    return $this;
  }


  function findBy($prop, $value) {
    return $this->model->where($prop, $value)->get();
  }

  function findById($id) {
    return $this->model->find($id);
  }

  function getAll() {
    return $this->model->all();
  }

  function insertIntoDatabase($data){
    $this->model->create($data);
    return $this;
  }


}

这取决于BaseRepository的实现。请添加一些代码。您可以在每个子存储库中使用
构造函数
注入。我将用其他信息更新问题
    <?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace App\Repositories;
use App\MbSurvey as Survey;

/**
 * Description of SurveyRepository
 *
 * @author Jordy
 */
class SurveyRepository extends BaseRepository implements RepositoryInterface {

function __construct() {
    $this->setModel(new Survey);
  }

}