movie-night-nuevo/app/Models/MovieList.php

32 lines
731 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
class MovieList extends Model
{
protected $fillable = [
'user_id',
'name',
'is_public'
];
public function movies(): BelongsToMany
{
return $this->belongsToMany(Movie::class);
}
public function owner(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
public function sharedUsers(): BelongsToMany
{
return $this->belongsToMany(User::class)->withPivot('permission')->withTimestamps();
}
}