そこで、Laravel 4.1 で Sentry 2 を実装しようとしています。このリソースを使用しています
https://github.com/rydurham/L4withSentry
すべて正常に動作しますが、登録時にユーザーをグループに自動的に割り当てたいと考えています。
セントリー 2 ドキュメントから、
// Find the group using the group id
$adminGroup = Sentry::findGroupById(5);
// Assign the group to the user
$user->addGroup($adminGroup);
動作するはずです。そこで、このコード行を Authority\Repo\User\SentryUser.php に追加しました
コードは次のようになります
try {
//Attempt to register the user.
$user = $this->sentry->register(array(
'username' => e($data['username']),
'email' => e($data['email']),
'password' => e($data['password'])
));
// Find the group using the group id
$adminGroup = Sentry::findGroupById(5);
// Assign the group to the user
$user->addGroup($adminGroup);
//success!
$result['success'] = true;
$result['message'] = trans('users.created');
$result['mailData']['activationCode'] = $user->GetActivationCode();
$result['mailData']['userId'] = $user->getId();
$result['mailData']['email'] = e($data['email']);
}
しかし、これはエラーをスローします
Non-static method Cartalyst\Sentry\Sentry::findGroupById() should not be called statically, assuming $this from incompatible context
誰かが光を当てて、私が間違っていることを教えてもらえますか? 前もって感謝します