File tree 2 files changed +8
-4
lines changed
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
1
<?php namespace GeneaLabs \LaravelGovernor \Listeners ;
2
2
3
- use Illuminate \Database \ Eloquent \ Model ;
3
+ use Illuminate \Support \ Facades \ Schema ;
4
4
5
5
class CreatedListener
6
6
{
7
7
/**
8
8
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
9
+ * @SuppressWarnings(PHPMD.StaticAccess)
9
10
*/
10
11
public function handle (string $ event , array $ models )
11
12
{
12
- foreach ($ models as $ model ) {
13
- if (get_class ($ model ) === config ('genealabs-laravel-governor.auth-model ' )) {
14
- $ model ->roles ()->attach ('Member ' );
13
+ if (Schema::hasTable ('roles ' )) {
14
+ foreach ($ models as $ model ) {
15
+ if (get_class ($ model ) === config ('genealabs-laravel-governor.auth-model ' )) {
16
+ $ model ->roles ()->attach ('Member ' );
17
+ }
15
18
}
16
19
}
17
20
}
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ public function boot(GateContract $gate)
56
56
__DIR__ . '/../../resources/views ' => base_path ('resources/views/vendor/genealabs/laravel-governor ' )
57
57
], 'views ' );
58
58
$ this ->loadViewsFrom (__DIR__ . '/../../resources/views ' , 'genealabs-laravel-governor ' );
59
+ $ this ->loadMigrationsFrom (__DIR__ . '/../../database/migrations ' );
59
60
60
61
if (Schema::hasTable ('entities ' )) {
61
62
$ this ->parsePolicies ($ gate );
You can’t perform that action at this time.
0 commit comments