Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\Entity;
- use AppBundle\Model\TimestampableInterface;
- use AppBundle\Model\TimestampableTrait;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- use JMS\Serializer\Annotation as JMS;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * @ORM\Table(
- * name="absences",
- * uniqueConstraints={@ORM\UniqueConstraint(
- * name="name_company",
- * columns={"company_id", "name"}
- * )}
- * )
- * @ORM\Entity(repositoryClass="AppBundle\Entity\Repository\AbsenceRepository")
- * @ORM\HasLifecycleCallbacks
- *
- * @UniqueEntity(
- * fields={"company", "name"},
- * ignoreNull=false,
- * message="company.absence_name_already_exists_for_selected_company"
- * )
- *
- * @JMS\ExclusionPolicy("all")
- */
- class Absence implements TimestampableInterface
- {
- use TimestampableTrait;
- const API_CARD = 'api__card';
- const SICK_LEAVE = 'sick_leave';
- const VACATION = 'vacation';
- const ARMY = 'army';
- const MATERNITY_LEAVE = 'maternity_leave';
- const UNPAID_VACATION = 'unpaid_vacation';
- const MOURNING = 'mourning';
- const TEAM_BUILDER_ACTIVITY = 'team_builder_activity';
- const HOLIDAY = 'holiday';
- /**
- * @var array
- */
- public static $defaultAbsences = [
- self::VACATION,
- self::SICK_LEAVE,
- self::UNPAID_VACATION,
- self::MATERNITY_LEAVE,
- self::HOLIDAY,
- self::ARMY,
- self::TEAM_BUILDER_ACTIVITY,
- self::MOURNING,
- ];
- /**
- * @var array
- */
- public static $absenceNumbers = [
- self::SICK_LEAVE => 1,
- self::VACATION => 2,
- self::ARMY => 3,
- self::MATERNITY_LEAVE => 4,
- self::UNPAID_VACATION => 5,
- self::MOURNING => 6,
- self::TEAM_BUILDER_ACTIVITY => 7,
- self::HOLIDAY => 8,
- ];
- public static $hebrewMap = [
- 'sick_leave' => 'מחלה',
- 'vacation' => 'חופשה',
- 'army' => 'צבא',
- 'maternity_leave' => 'חופשת לידה',
- 'unpaid_vacation' => 'חל"ת',
- 'mourning' => 'אבל',
- 'team_builder_activity' => 'פעילות גיבוש בחברה',
- 'holiday' => 'חג',
- ];
- public static $englishMap = [
- 'sick_leave' => 'Sick leave',
- 'vacation' => 'Vacation',
- 'army' => 'Army',
- 'maternity_leave' => 'Maternity leave',
- 'unpaid_vacation' => 'Unpaid vacation',
- 'mourning' => 'Mourning',
- 'team_builder_activity' => 'Team builder activity',
- 'holiday' => 'Holiday',
- ];
- /**
- * @var int
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var string
- *
- * @Assert\NotBlank()
- *
- * @JMS\Expose()
- * @JMS\Groups({Absence::API_CARD})
- *
- * @ORM\Column(name="name", type="string")
- */
- private $name;
- /**
- * @var bool
- *
- * @ORM\Column(name="paid", type="boolean", options={"default" = false})
- */
- private $paid = false;
- /**
- * @var int|null
- *
- * @ORM\Column(name="michpal_number", type="integer", nullable=true)
- */
- private $michpalNumber;
- /**
- * @var Companies
- *
- * @Assert\NotNull()
- *
- * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Companies", cascade={"persist"}, inversedBy="absences")
- * @ORM\JoinColumn(name="company_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
- */
- private $company;
- /**
- * @var ActivityLog[]|ArrayCollection
- *
- * @ORM\OneToMany(targetEntity="AppBundle\Entity\ActivityLog", mappedBy="absence")
- */
- private $sessions;
- public function __construct()
- {
- $this->sessions = new ArrayCollection();
- }
- /**
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @param string $name
- *
- * @return Absence
- */
- public function setName($name)
- {
- $this->name = $name;
- return $this;
- }
- /**
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * @param bool $paid
- *
- * @return Absence
- */
- public function setPaid($paid)
- {
- $this->paid = $paid;
- return $this;
- }
- /**
- * @return bool
- */
- public function isPaid()
- {
- return $this->paid;
- }
- /**
- * @param int|null $michpalNumber
- *
- * @return Absence
- */
- public function setMichpalNumber($michpalNumber)
- {
- $this->michpalNumber = $michpalNumber;
- return $this;
- }
- /**
- * @return int|null
- */
- public function getMichpalNumber()
- {
- return $this->michpalNumber;
- }
- /**
- * @param Companies $company
- *
- * @return Absence
- */
- public function setCompany($company)
- {
- $this->company = $company;
- return $this;
- }
- /**
- * @return Companies
- */
- public function getCompany()
- {
- return $this->company;
- }
- /**
- * @param ActivityLog[]|ArrayCollection $sessions
- *
- * @return Absence
- */
- public function setSessions($sessions)
- {
- $this->sessions = $sessions;
- return $this;
- }
- /**
- * @return ActivityLog[]|ArrayCollection
- */
- public function getSessions()
- {
- return $this->sessions;
- }
- /**
- * @return string
- */
- public function __toString()
- {
- return $this->getName();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement