<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Constant\BandMemberRoleConstant;
use App\Constant\FileStatusConstant;
/**
* BandMember
*
* @ORM\Table(name="band_member")
* @ORM\Entity
*/
class BandMember
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private int $id;
/**
* @ORM\ManyToOne(targetEntity="Band", inversedBy="members")
* @ORM\JoinColumn(nullable=false)
*/
private Band $band;
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="bands")
* @ORM\JoinColumn(nullable=false)
*/
private User $user;
/**
* @var string|null
*
* @ORM\Column(name="story", type="text", nullable=true)
*/
private ?string $story;
/**
* @ORM\ManyToMany(targetEntity="Instrument", orphanRemoval=false)
*/
private Collection $instruments;
/**
* @var integer
*
* @ORM\Column(name="role", type="string", length=255)
*/
private $role = BandMemberRoleConstant::MEMBER;
/**
* @ORM\OneToMany(targetEntity="FileBandMember", mappedBy="bandMember", cascade={"remove"})
*/
private Collection $files;
/**
* Constructor
*/
public function __construct()
{
$this->instruments = new ArrayCollection();
$this->files = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId(): int
{
return $this->id;
}
/**
* Set story
*
* @param string $story
*
* @return BandMember
*/
public function setStory(string $story): BandMember
{
$this->story = $story;
return $this;
}
/**
* Get story
*
* @return string|null
*/
public function getStory(): ?string
{
return $this->story;
}
/**
* Set band
*
* @param Band $band
*
* @return BandMember
*/
public function setBand(Band $band): BandMember
{
$this->band = $band;
return $this;
}
/**
* Get band
*
* @return Band
*/
public function getBand(): Band
{
return $this->band;
}
/**
* Add instrument
*
* @param Instrument $instrument
*
* @return BandMember
*/
public function addInstrument(Instrument $instrument): BandMember
{
$this->instruments[] = $instrument;
return $this;
}
/**
* Remove instrument
*
* @param Instrument $instrument
*/
public function removeInstrument(Instrument $instrument)
{
$this->instruments->removeElement($instrument);
}
/**
* Get instruments
*
* @return Collection
*/
public function getInstruments(): Collection
{
return $this->instruments;
}
/**
* Set user
*
* @param User $user
*
* @return BandMember
*/
public function setUser(User $user): BandMember
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return User
*/
public function getUser(): User
{
return $this->user;
}
/**
* Add file
*
* @param FileBandMember $file
*
* @return BandMember
*/
public function addFile(FileBandMember $file): BandMember
{
$this->files[] = $file;
return $this;
}
/**
* Remove file
*
* @param FileBandMember $file
*/
public function removeFile(FileBandMember $file)
{
$this->files->removeElement($file);
}
/**
* Get files
*
* @return Collection
*/
public function getAllFiles(): Collection
{
return $this->files;
}
/**
* Get files
*
* @return Collection
*/
public function getFiles(): Collection
{
return $this->files->filter(function($fbm){
return !$fbm->getFile()->getDeleted()
&& $fbm->getFile()->getStatus() == FileStatusConstant::STATUS_PUBLIC;
});
}
/**
* Set role
*
* @param string $role
*
* @return BandMember
*/
public function setRole(string $role): BandMember
{
$this->role = $role;
return $this;
}
/**
* Get role
*
* @return string
*/
public function getRole()
{
return $this->role;
}
}