diff --git a/src/Traits/HasAccess.php b/src/Traits/HasAccess.php index 83cc99f..b199dfc 100644 --- a/src/Traits/HasAccess.php +++ b/src/Traits/HasAccess.php @@ -22,8 +22,10 @@ protected static function bootHasAccess() { if(request()->has('role')) { - if($model->role->id != request()->role) + if(is_null($model->role)) { + RoleEvent::dispatch('created', $model); + } else if($model->role->id != request()->role) { RoleEvent::dispatch('updated', $model); } $model->role()->associate(request()->role);