feat: add UserMovie join entity
This commit is contained in:
55
src/Entity/UserMovie.php
Normal file
55
src/Entity/UserMovie.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\UserMovieRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: UserMovieRepository::class)]
|
||||
#[ORM\UniqueConstraint(name: 'user_movie_unique', columns: ['user_id', 'movie_id'])]
|
||||
class UserMovie
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Movie::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Movie $movie = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMovie(): ?Movie
|
||||
{
|
||||
return $this->movie;
|
||||
}
|
||||
|
||||
public function setMovie(?Movie $movie): static
|
||||
{
|
||||
$this->movie = $movie;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
20
src/Repository/UserMovieRepository.php
Normal file
20
src/Repository/UserMovieRepository.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\UserMovie;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<UserMovie>
|
||||
*/
|
||||
class UserMovieRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, UserMovie::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user