为什么我的模型在serviceRepository laravel中不起作用?

时间:2014-12-01 11:39:45

标签: php laravel laravel-5

我在这里有一个服务提供商以及http://dfg.gd/blog/decoupling-your-code-in-laravel-using-repositiories-and-services 我的服务提供商:

class UsersRepositoryServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->bind('App\Repositories\Users\UsersInterface', function($app)
        {

            return new UsersRepository(new User);

        });
    }

我收到错误:Call to a member function find() on a non-object 我的存储库:

use \Illuminate\Database\Eloquent\Model;
//..
protected $usersModel;

public function __consturct(Model $users)
{
    $this->usersModel = $users;
}

/**
 * Get user by id
 * 
 * @param mixed $userId
 * @return Model
 */
public function getUserById($userId)
{
    return $this->convertFormat($this->usersModel->find($userId));
}

1 个答案:

答案 0 :(得分:0)

__ consturct拼错了。

正确是__construct