Commit 3dceb47a authored by SpinShare's avatar SpinShare

added SongReview and SongSpinPlay entities

parent cb44095a
......@@ -2,6 +2,8 @@
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
......@@ -101,6 +103,27 @@ class Song
*/
private $uploadDate;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\OneToMany(targetEntity="App\Entity\SongReview", mappedBy="song", orphanRemoval=true)
*/
private $reviews;
/**
* @ORM\OneToMany(targetEntity="App\Entity\SongSpinPlay", mappedBy="song", orphanRemoval=true)
*/
private $spinPlays;
public function __construct()
{
$this->reviews = new ArrayCollection();
$this->spinPlays = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
......@@ -309,4 +332,78 @@ class Song
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection|SongReview[]
*/
public function getReviews(): Collection
{
return $this->reviews;
}
public function addReview(SongReview $review): self
{
if (!$this->reviews->contains($review)) {
$this->reviews[] = $review;
$review->setSong($this);
}
return $this;
}
public function removeReview(SongReview $review): self
{
if ($this->reviews->contains($review)) {
$this->reviews->removeElement($review);
// set the owning side to null (unless already changed)
if ($review->getSong() === $this) {
$review->setSong(null);
}
}
return $this;
}
/**
* @return Collection|SongSpinPlay[]
*/
public function getSpinPlays(): Collection
{
return $this->spinPlays;
}
public function addSpinPlay(SongSpinPlay $spinPlay): self
{
if (!$this->spinPlays->contains($spinPlay)) {
$this->spinPlays[] = $spinPlay;
$spinPlay->setSong($this);
}
return $this;
}
public function removeSpinPlay(SongSpinPlay $spinPlay): self
{
if ($this->spinPlays->contains($spinPlay)) {
$this->spinPlays->removeElement($spinPlay);
// set the owning side to null (unless already changed)
if ($spinPlay->getSong() === $this) {
$spinPlay->setSong(null);
}
}
return $this;
}
}
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\SongReviewRepository")
*/
class SongReview
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\User", inversedBy="reviews")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Song", inversedBy="reviews")
* @ORM\JoinColumn(nullable=false)
*/
private $song;
/**
* @ORM\Column(type="boolean")
*/
private $recommended;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* @ORM\Column(type="datetime")
*/
private $reviewDate;
public function __construct()
{
$this->user = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection|User[]
*/
public function getUser(): Collection
{
return $this->user;
}
public function addUser(User $user): self
{
if (!$this->user->contains($user)) {
$this->user[] = $user;
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->user->contains($user)) {
$this->user->removeElement($user);
}
return $this;
}
public function getSong(): ?Song
{
return $this->song;
}
public function setSong(?Song $song): self
{
$this->song = $song;
return $this;
}
public function getRecommended(): ?bool
{
return $this->recommended;
}
public function setRecommended(bool $recommended): self
{
$this->recommended = $recommended;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getReviewDate(): ?\DateTimeInterface
{
return $this->reviewDate;
}
public function setReviewDate(\DateTimeInterface $reviewDate): self
{
$this->reviewDate = $reviewDate;
return $this;
}
}
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\SongSpinPlayRepository")
*/
class SongSpinPlay
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\User", inversedBy="spinPlays")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Song", inversedBy="spinPlays")
* @ORM\JoinColumn(nullable=false)
*/
private $song;
/**
* @ORM\Column(type="string", length=255)
*/
private $videoUrl;
/**
* @ORM\Column(type="datetime")
*/
private $submitDate;
/**
* @ORM\Column(type="boolean")
*/
private $isActive;
public function __construct()
{
$this->user = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection|User[]
*/
public function getUser(): Collection
{
return $this->user;
}
public function addUser(User $user): self
{
if (!$this->user->contains($user)) {
$this->user[] = $user;
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->user->contains($user)) {
$this->user->removeElement($user);
}
return $this;
}
public function getSong(): ?Song
{
return $this->song;
}
public function setSong(?Song $song): self
{
$this->song = $song;
return $this;
}
public function getVideoUrl(): ?string
{
return $this->videoUrl;
}
public function setVideoUrl(string $videoUrl): self
{
$this->videoUrl = $videoUrl;
return $this;
}
public function getSubmitDate(): ?\DateTimeInterface
{
return $this->submitDate;
}
public function setSubmitDate(\DateTimeInterface $submitDate): self
{
$this->submitDate = $submitDate;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
}
......@@ -3,6 +3,8 @@
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
......@@ -34,9 +36,21 @@
*/
private $isPatreon;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\SongReview", mappedBy="user")
*/
private $reviews;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\SongSpinPlay", mappedBy="user")
*/
private $spinPlays;
public function __construct()
{
parent::__construct();
$this->reviews = new ArrayCollection();
$this->spinPlays = new ArrayCollection();
// your own logic
}
......@@ -75,4 +89,60 @@
return $this;
}
/**
* @return Collection|SongReview[]
*/
public function getReviews(): Collection
{
return $this->reviews;
}
public function addReview(SongReview $review): self
{
if (!$this->reviews->contains($review)) {
$this->reviews[] = $review;
$review->addUser($this);
}
return $this;
}
public function removeReview(SongReview $review): self
{
if ($this->reviews->contains($review)) {
$this->reviews->removeElement($review);
$review->removeUser($this);
}
return $this;
}
/**
* @return Collection|SongSpinPlay[]
*/
public function getSpinPlays(): Collection
{
return $this->spinPlays;
}
public function addSpinPlay(SongSpinPlay $spinPlay): self
{
if (!$this->spinPlays->contains($spinPlay)) {
$this->spinPlays[] = $spinPlay;
$spinPlay->addUser($this);
}
return $this;
}
public function removeSpinPlay(SongSpinPlay $spinPlay): self
{
if ($this->spinPlays->contains($spinPlay)) {
$this->spinPlays->removeElement($spinPlay);
$spinPlay->removeUser($this);
}
return $this;
}
}
\ No newline at end of file
<?php
namespace App\Repository;
use App\Entity\SongReview;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
/**
* @method SongReview|null find($id, $lockMode = null, $lockVersion = null)
* @method SongReview|null findOneBy(array $criteria, array $orderBy = null)
* @method SongReview[] findAll()
* @method SongReview[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class SongReviewRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, SongReview::class);
}
// /**
// * @return SongReview[] Returns an array of SongReview objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('s')
->andWhere('s.exampleField = :val')
->setParameter('val', $value)
->orderBy('s.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?SongReview
{
return $this->createQueryBuilder('s')
->andWhere('s.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}
<?php
namespace App\Repository;
use App\Entity\SongSpinPlay;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
/**
* @method SongSpinPlay|null find($id, $lockMode = null, $lockVersion = null)
* @method SongSpinPlay|null findOneBy(array $criteria, array $orderBy = null)
* @method SongSpinPlay[] findAll()
* @method SongSpinPlay[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class SongSpinPlayRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, SongSpinPlay::class);
}
// /**
// * @return SongSpinPlay[] Returns an array of SongSpinPlay objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('s')
->andWhere('s.exampleField = :val')
->setParameter('val', $value)
->orderBy('s.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?SongSpinPlay
{
return $this->createQueryBuilder('s')
->andWhere('s.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment