added support for inviting list collaborators

This commit is contained in:
Edward Tirado Jr 2026-04-03 00:39:37 -05:00
parent cd2c8adaa8
commit 0787b75780
21 changed files with 393 additions and 34 deletions

View file

@ -6,5 +6,13 @@ use Illuminate\Database\Eloquent\Model;
class Invitation extends Model
{
//
const EXPIRATION_DAYS = 7;
protected $fillable = [
'email',
'token',
'movie_list_id',
'status',
'expires_at',
];
}

View file

@ -18,4 +18,9 @@ class MovieList extends Model
{
return $this->belongsToMany(Movie::class);
}
public function collaborators(): BelongsToMany
{
return $this->belongsToMany(User::class, 'movie_list_user');
}
}

View file

@ -4,6 +4,8 @@ namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
@ -21,7 +23,6 @@ class User extends Authenticatable
protected $fillable = [
'username',
'email',
'password',
];
/**
@ -34,6 +35,21 @@ class User extends Authenticatable
'remember_token',
];
public function profile(): HasOne
{
return $this->hasOne(Profile::class);
}
public function movieLists(): HasMany
{
return $this->hasMany(MovieList::class, 'owner');
}
public function sharedLists(): BelongsToMany
{
return $this->belongsToMany(MovieList::class)->withPivot('role')->withTimestamps();
}
/**
* Get the attributes that should be cast.
*
@ -46,9 +62,4 @@ class User extends Authenticatable
'password' => 'hashed',
];
}
public function profile(): HasOne
{
return $this->hasOne(Profile::class);
}
}