Skip to content

Commit b2345e9

Browse files
author
Nikita Teryaev
committed
fix default model in repos
1 parent 5f5023e commit b2345e9

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

app/Authentication/Repository/SentryGroupRepository.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@ class SentryGroupRepository extends EloquentBaseRepository implements BaseReposi
2222

2323
protected $config_reader;
2424

25+
protected $groupModel = \LaravelAcl\Authentication\Models\Group::class;
26+
2527
public function __construct($config_reader = null)
2628
{
2729
$this->sentry = App::make('sentry');
2830
$this->config_reader = $config_reader ? $config_reader : App::make('config');
2931

30-
return parent::__construct( $this->sentry->getGroupProvider()->createModel() );
31-
}
32+
if (method_exists($this->sentry, 'getGroupProvider')) {
33+
$this->groupModel = get_class( $this->sentry->getGroupProvider()->createModel());
34+
}
3235

36+
return parent::__construct( new $this->groupModel );
37+
}
3338
/**
3439
* Create a new object
3540
*

app/Authentication/Repository/SentryUserRepository.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use Illuminate\Support\Facades\Config;
1616
use LaravelAcl\Authentication\Exceptions\UserExistsException;
1717
use LaravelAcl\Authentication\Exceptions\UserNotFoundException as NotFoundException;
18-
use LaravelAcl\Authentication\Models\Group;
19-
use LaravelAcl\Authentication\Models\User;
2018
use LaravelAcl\Authentication\Repository\Interfaces\UserRepositoryInterface;
2119
use LaravelAcl\Library\Repository\EloquentBaseRepository;
2220

@@ -29,14 +27,22 @@ class SentryUserRepository extends EloquentBaseRepository implements UserReposit
2927
*/
3028
protected $sentry;
3129

32-
protected $groupModel = NULL;
30+
protected $groupModel = \LaravelAcl\Authentication\Models\Group::class;
31+
protected $userModel = \LaravelAcl\Authentication\Models\User::class;
3332

3433
public function __construct()
3534
{
3635
$this->sentry = App::make('sentry');
37-
$this->groupModel = $this->sentry->getGroupProvider();
3836

39-
return parent::__construct( $this->sentry->getUserProvider()->createModel() );
37+
if (method_exists($this->sentry, 'getGroupProvider')) {
38+
$this->groupModel = get_class( $this->sentry->getGroupProvider()->createModel());
39+
}
40+
41+
if (method_exists($this->sentry, 'getUserProvider')) {
42+
$this->userModel = get_class ($this->sentry->getUserProvider()->createModel());
43+
}
44+
45+
return parent::__construct( new $this->userModel );
4046
}
4147

4248
/**

0 commit comments

Comments
 (0)