-
Notifications
You must be signed in to change notification settings - Fork 840
Open
Description
Jetstream Version
5.1.1
Jetstream Stack
Livewire
Laravel Version
12.34.0
PHP Version
8.4.13
Database Driver & Version
No response
Description
Calling hasTeamRole($team, $role) on the HasTeams trait can result in a runtime error when the team_user.role column is null.
The Jetstream migration allows the role column to be nullable
The method passes the value directly into Jetstream::findRole which does not allow null.
Steps To Reproduce
<?php
use App\Models\Team;
use App\Models\User;
use Laravel\Jetstream\Tests\Fixtures\User as UserFixture;
use Laravel\Jetstream\Tests\OrchestraTestCase;
class HasTeamRoleTest extends OrchestraTestCase
{
public function test_hasTeamRole_returns_false_when_member_pivot_role_is_null(): void
{
$team = Team::factory()->create();
$user = UserFixture::find(User::factory()->create()->id);
$user->teams()->attach($team, ['role' => null]);
$this->assertFalse($user->hasTeamRole($team, 'admin'));
}
}Related Pull Request
See #1584 for a proposed fix. This issue documents the underlying bug for clarity.
Metadata
Metadata
Assignees
Labels
No labels