GeolocEntityTrait.php 796 Bytes
Newer Older
Julien Jorry committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
<?php

namespace App\Entity\EntityTrait;

use App\Entity\Geoloc;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

trait GeolocEntityTrait
{
    /**
     * @var Geoloc
     *
     * @ORM\OneToOne(targetEntity="Geoloc", cascade={"persist"}, orphanRemoval=true)
     * @Groups({"read", "write"})
     */
    private $geoloc;

    public function getGeoloc(): ?Geoloc
    {
        return $this->geoloc;
    }

    public function setGeoloc(Geoloc $geoloc)
    {
        $this->geoloc = $geoloc;
27

Julien Jorry committed
28 29 30 31 32
        return $this;
    }

    public function getFullAddresse()
    {
33 34
        if (null != $this->geoloc) {
            return $this->geoloc->getAdresse() . ' ' . $this->geoloc->getCpostal() . ' ' . $this->geoloc->getVille();
Julien Jorry committed
35
        }
36

Julien Jorry committed
37 38 39
        return '';
    }
}