Skip to content

Commit 218782c

Browse files
committed
Fixed issue with adding owner role when creating team
1 parent acc1c3f commit 218782c

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
### Fixed
2020
### Removed --->
2121

22+
## 0.9.7 - 2021-11-27
23+
### Fixed
24+
- Issue with adding owner role when creating new team
25+
2226
## 0.9.6 - 2021-11-24
2327
### Added
2428
- Related organisations and people

config/package.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
|
1414
*/
1515

16-
'version' => '0.9.6',
16+
'version' => '0.9.7',
1717

1818
];

src/Http/Middleware/TeamsPermission.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function handle($request, Closure $next)
1818
return $next($request);
1919
}
2020

21-
if (config('laravel-crm.teams')) {
21+
if (config('laravel-crm.teams') && auth()->user()->currentTeam) {
2222
app(\Spatie\Permission\PermissionRegistrar::class)->setPermissionsTeamId(auth()->user()->currentTeam->id);
2323
}
2424

src/Observers/TeamObserver.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,15 @@ public function created(Team $team)
6868

6969
if ($role = Role::where([
7070
'name' => 'Owner',
71-
'team_id' => auth()->user()->currentTeam->id,
71+
'team_id' => $team->id,
7272
'crm_role' => 1,
7373
])->first()) {
74-
auth()->user()->assignRole($role);
74+
DB::table('model_has_roles')->insert([
75+
'role_id' => $role->id,
76+
'model_type' => auth()->user()->getMorphClass(),
77+
'model_id' => auth()->user()->id,
78+
'team_id' => $team->id,
79+
]);
7580
}
7681

7782
foreach (DB::table('labels')

0 commit comments

Comments
 (0)