Skip to content

Commit 311891c

Browse files
authored
Merge pull request #98 from mikebronner/upgrade-to-laravel-12-and-modernize-functionality
Modernize Functionality
2 parents 6eae11a + 734b17a commit 311891c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

database/migrations/0001_01_02_000009_create_governor_team_invitations_table.php

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function __construct()
1616

1717
public function up(): void
1818
{
19+
1920
Schema::create('governor_team_invitations', function (Blueprint $table): void {
2021
$user = app(config('genealabs-laravel-governor.models.auth'));
2122

src/Listeners/CreatedTeamListener.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class CreatedTeamListener
44
{
55
public function handle($team)
66
{
7-
$team->members()->syncWithoutDetaching([auth()->user()->id]);
7+
if (auth()->check()) {
8+
$team->members()->syncWithoutDetaching([auth()->user()->id]);
9+
}
810
}
911
}

src/Traits/GovernorOwnedByField.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ protected function createGovernorOwnedByFieldsByPolicy(BasePolicy $policy): bool
3333

3434
protected function createGovernorOwnedByFields(Model $model): bool
3535
{
36-
if (! in_array("GeneaLabs\\LaravelGovernor\\Traits\\Governable", class_uses_recursive($model))) {
36+
$class = new ReflectionClass($model);
37+
38+
if (
39+
(! in_array("GeneaLabs\\LaravelGovernor\\Traits\\Governable", class_uses_recursive($model))
40+
&& ! in_array("GeneaLabs\\LaravelGovernor\\Traits\\Governing", class_uses_recursive($model)))
41+
|| $class->isAbstract()
42+
) {
3743
return false;
3844
}
3945

0 commit comments

Comments
 (0)