Adherent.php 2.38 KB
Newer Older
Julien Jorry committed
1 2 3 4
<?php

namespace App\Entity;

5 6
use App\Entity\EntityTrait\EnablableEntityTrait;
use App\Entity\EntityTrait\GeolocEntityTrait;
Julien Jorry committed
7
use Doctrine\ORM\Mapping as ORM;
8
use Gedmo\Timestampable\Traits\TimestampableEntity;
Julien Jorry committed
9 10 11

/**
 * @ORM\Entity(repositoryClass="App\Repository\AdherentRepository")
12
 * @ORM\Table(name="adherent")
Julien Jorry committed
13 14 15
 */
class Adherent
{
16
    use EnablableEntityTrait,
17
        TimestampableEntity,
18 19
        GeolocEntityTrait;

Julien Jorry committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="decimal", precision=7, scale=2)
     */
    private $ecompte;

    /**
     * @var User
     *
35
     * @ORM\OneToOne(targetEntity="User", cascade={"all"}, mappedBy="adherent", fetch="LAZY")
Julien Jorry committed
36 37 38
     */
    protected $user;

39 40 41
    /**
     * @var Groupe $groupe
     *
Julien Jorry committed
42
     * @ORM\ManyToOne(targetEntity="Groupe", inversedBy="adherents")
43 44 45
     */
    private $groupe;

Julien Jorry committed
46 47 48 49 50
    public function getId(): ?int
    {
        return $this->id;
    }

51
    public function getEcompte(): float
Julien Jorry committed
52 53 54 55
    {
        return $this->ecompte;
    }

56 57 58 59 60 61 62 63 64 65 66 67 68
    public function setEcompte(float $ecompte): self
    {
        $this->ecompte = $ecompte;

        return $this;
    }

    public function getCompte(): float
    {
        return $this->ecompte;
    }

    public function setCompte(float $ecompte): self
Julien Jorry committed
69 70 71 72 73 74 75 76 77
    {
        $this->ecompte = $ecompte;

        return $this;
    }

    /**
     * @return User
     */
78
    public function getUser(): ?User
Julien Jorry committed
79 80 81 82 83 84 85 86 87 88 89 90 91
    {
        return $this->user;
    }

    /**
     * @param User $user
     * @return Prestataire
     */
    public function setUser(User $user): self
    {
        $this->user = $user;
        return $this;
    }
Julien Jorry committed
92

93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
    /**
     * @param null|Groupe $groupe
     * @return $this
     */
    public function setGroupe(?Groupe $groupe)
    {
        $this->groupe = $groupe;
        return $this;
    }

    /**
     * @return null|Groupe
     */
    public function getGroupe(): ?Groupe
    {
        return $this->groupe;
    }


Julien Jorry committed
112 113 114 115 116 117 118 119 120 121 122
    public function isEnabled(): bool
    {
        return $this->getUser()->isEnabled();
    }

    public function setEnabled($enabled): self
    {
        $this->getUser()->setEnabled($enabled);
        return $this;
    }

123 124 125 126
    public function __toString(): string
    {
        return (!empty($this->getUser() && $this->getUser()->getUsername())?$this->getUser()->getUsername():'Adherent '.$this->getId());
    }
Julien Jorry committed
127
}