moved roles to a separate database and added code to make updates

This commit is contained in:
Edward Tirado Jr 2026-04-09 18:30:16 -05:00
parent 985f339725
commit 836ef8f1f6
14 changed files with 317 additions and 21 deletions

View file

@ -27,18 +27,19 @@ class MovieList extends Model
return $this->belongsToMany(Movie::class);
}
public function getUserRole($userId)
public function getUserRole($userId): string
{
return $this->collaborators()
$roleId = $this->collaborators()
->where('user_id', $userId)
->first()
?->pivot
->role;
?->pivot->role_id;
return Role::query()->find($roleId)?->name;
}
public function collaborators(): BelongsToMany
{
return $this->belongsToMany(User::class, 'movie_list_user')
->withPivot('role');
->withPivot('role_id');
}
}