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

@ -45,9 +45,19 @@ class User extends Authenticatable
return $this->hasMany(MovieList::class, 'owner');
}
public function hasRole(MovieList $movieList, int $role): bool
{
return $this->sharedLists()
->wherePivot('movie_list_id', $movieList->id)
->wherePivot('role_id', $role)
->exists();
}
public function sharedLists(): BelongsToMany
{
return $this->belongsToMany(MovieList::class)->withPivot('role')->withTimestamps();
return $this->belongsToMany(MovieList::class)
->withPivot('role_id')
->withTimestamps();
}
/**