我试图在Eloquent模型中调用Sentry::
。但是,我收到了错误
Non-static method Cartalyst\Sentry\Sentry::getUserProvider() should not be called statically, assuming $this from incompatible context
目前的代码如下。我做错了什么?
<?php
namespace App\Model;
use Cartalyst\Sentry\Users\Eloquent\User as CartalystUser;
use Cartalyst\Sentry\Sentry;
class User extends CartalystUser {
protected $table = 'users';
protected $hidden = array('password');
public function __construct() {
$users = Sentry::getUserProvider()->findAll();
print_r($users);
exit;
}
public function brands() {
return $this->hasMany('Brand');
}
}
?>
答案 0 :(得分:2)
Sentry::getUserProvider()
。
如果您想扩展Sentry\User
模型,请按以下方式创建模型:
class User extends Cartalyst\Sentry\Users\Eloquent\User { ... }
答案 1 :(得分:0)
对于您的问题,我的答案很可能为时已晚,但对其他开发者而言可能会有所帮助。
答案:只需编辑你的命名空间。
更改:使用Cartalyst \ Sentry \ Sentry;
收件人:使用Sentry;