src/Entity/BandMember.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Constant\BandMemberRoleConstant;
  7. use App\Constant\FileStatusConstant;
  8. /**
  9.  * BandMember
  10.  *
  11.  * @ORM\Table(name="band_member")
  12.  * @ORM\Entity
  13.  */
  14. class BandMember
  15. {
  16.     /**
  17.      * @var int
  18.      *
  19.      * @ORM\Column(name="id", type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     private int $id;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity="Band", inversedBy="members")
  26.      * @ORM\JoinColumn(nullable=false)
  27.      */
  28.     private Band $band;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity="User", inversedBy="bands")
  31.      * @ORM\JoinColumn(nullable=false)
  32.      */
  33.     private User $user;
  34.     /**
  35.      * @var string|null
  36.      *
  37.      * @ORM\Column(name="story", type="text", nullable=true)
  38.      */
  39.     private ?string $story;
  40.     /**
  41.      * @ORM\ManyToMany(targetEntity="Instrument", orphanRemoval=false)
  42.      */
  43.     private Collection $instruments;
  44.     /**
  45.      * @var integer
  46.      *
  47.      * @ORM\Column(name="role", type="string", length=255)
  48.      */
  49.     private $role BandMemberRoleConstant::MEMBER;
  50.     /**
  51.      * @ORM\OneToMany(targetEntity="FileBandMember", mappedBy="bandMember", cascade={"remove"})
  52.      */
  53.     private Collection $files;
  54.     /**
  55.      * Constructor
  56.      */
  57.     public function __construct()
  58.     {
  59.         $this->instruments = new ArrayCollection();
  60.         $this->files = new ArrayCollection();
  61.     }
  62.     /**
  63.      * Get id
  64.      *
  65.      * @return integer
  66.      */
  67.     public function getId(): int
  68.     {
  69.         return $this->id;
  70.     }
  71.     /**
  72.      * Set story
  73.      *
  74.      * @param string $story
  75.      *
  76.      * @return BandMember
  77.      */
  78.     public function setStory(string $story): BandMember
  79.     {
  80.         $this->story $story;
  81.         return $this;
  82.     }
  83.     /**
  84.      * Get story
  85.      *
  86.      * @return string|null
  87.      */
  88.     public function getStory(): ?string
  89.     {
  90.         return $this->story;
  91.     }
  92.     /**
  93.      * Set band
  94.      *
  95.      * @param Band $band
  96.      *
  97.      * @return BandMember
  98.      */
  99.     public function setBand(Band $band): BandMember
  100.     {
  101.         $this->band $band;
  102.         return $this;
  103.     }
  104.     /**
  105.      * Get band
  106.      *
  107.      * @return Band
  108.      */
  109.     public function getBand(): Band
  110.     {
  111.         return $this->band;
  112.     }
  113.     /**
  114.      * Add instrument
  115.      *
  116.      * @param Instrument $instrument
  117.      *
  118.      * @return BandMember
  119.      */
  120.     public function addInstrument(Instrument $instrument): BandMember
  121.     {
  122.         $this->instruments[] = $instrument;
  123.         return $this;
  124.     }
  125.     /**
  126.      * Remove instrument
  127.      *
  128.      * @param Instrument $instrument
  129.      */
  130.     public function removeInstrument(Instrument $instrument)
  131.     {
  132.         $this->instruments->removeElement($instrument);
  133.     }
  134.     /**
  135.      * Get instruments
  136.      *
  137.      * @return Collection
  138.      */
  139.     public function getInstruments(): Collection
  140.     {
  141.         return $this->instruments;
  142.     }
  143.     /**
  144.      * Set user
  145.      *
  146.      * @param User $user
  147.      *
  148.      * @return BandMember
  149.      */
  150.     public function setUser(User $user): BandMember
  151.     {
  152.         $this->user $user;
  153.         return $this;
  154.     }
  155.     /**
  156.      * Get user
  157.      *
  158.      * @return User
  159.      */
  160.     public function getUser(): User
  161.     {
  162.         return $this->user;
  163.     }
  164.     /**
  165.      * Add file
  166.      *
  167.      * @param FileBandMember $file
  168.      *
  169.      * @return BandMember
  170.      */
  171.     public function addFile(FileBandMember $file): BandMember
  172.     {
  173.         $this->files[] = $file;
  174.         return $this;
  175.     }
  176.     /**
  177.      * Remove file
  178.      *
  179.      * @param FileBandMember $file
  180.      */
  181.     public function removeFile(FileBandMember $file)
  182.     {
  183.         $this->files->removeElement($file);
  184.     }
  185.     /**
  186.      * Get files
  187.      *
  188.      * @return Collection
  189.      */
  190.     public function getAllFiles(): Collection
  191.     {
  192.         return $this->files;
  193.     }
  194.     /**
  195.      * Get files
  196.      *
  197.      * @return Collection
  198.      */
  199.     public function getFiles(): Collection
  200.     {
  201.         return $this->files->filter(function($fbm){
  202.             return !$fbm->getFile()->getDeleted()
  203.                 && $fbm->getFile()->getStatus() == FileStatusConstant::STATUS_PUBLIC;
  204.         });
  205.     }
  206.     /**
  207.      * Set role
  208.      *
  209.      * @param string $role
  210.      *
  211.      * @return BandMember
  212.      */
  213.     public function setRole(string $role): BandMember
  214.     {
  215.         $this->role $role;
  216.         return $this;
  217.     }
  218.     /**
  219.      * Get role
  220.      *
  221.      * @return string
  222.      */
  223.     public function getRole()
  224.     {
  225.         return $this->role;
  226.     }
  227. }