Prestataire.php 9.72 KB
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
<?php

namespace App\Entity;

use App\Entity\EntityTrait\EnablableEntityTrait;
use App\Entity\EntityTrait\GeolocEntityTrait;
use App\Entity\EntityTrait\HasCompteEntity;
use App\Entity\Groupeprestataire;
use App\Entity\Image;
use App\Entity\Rubrique;
use App\Entity\TypePrestataire;
use App\Entity\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name="prestataire")
 */
class Prestataire
{
    use EnablableEntityTrait,
        GeolocEntityTrait,
        HasCompteEntity;

    const UPLOAD_DIR = "prestataire";

    /**
     * @var int
     *
     * @ORM\Id
     * @ORM\Column(name="id", type="integer")
     * @ORM\GeneratedValue
     */
    protected $id;

    /**
     * @var string
     *
     * @ORM\Column(name="raison", type="string", length=100)
     */
    private $raison;

    /**
     * @var string
     *
     * @ORM\Column(name="metier", type="string", length=100)
     */
    private $metier;

    /**
     * @var null|string
     *
     * @ORM\Column(name="statut", type="string", length=50, nullable=true)
     */
    private $statut;

    /**
     * @var null|string
     *
     * @ORM\Column(name="responsable", type="string", length=200, nullable=true)
     */
    private $responsable;

    /**
     * @var string
     *
     * @ORM\Column(name="iban", type="string", length=100)
     */
    private $iban;

    /**
     * @var string
     *
     * @ORM\Column(name="siret", type="string", length=50)
     */
    private $siret;

    /**
     * @var null|string
     *
     * @ORM\Column(name="web", type="string", length=255, nullable=true)
     */
    private $web;

    /**
     * @var bool
     *
     * @ORM\Column(name="accept", type="boolean", nullable=false)
     */
    private $accept = false;

    /**
     * @var null|string (champ libre)
     *
     * @ORM\Column(name="horaires", type="string", length=255, nullable=true)
     */
    private $horaires;

    /**
     * @var TypePrestataire
     *
     * @ORM\ManyToOne(targetEntity="TypePrestataire", cascade={"persist"}, inversedBy="prestataires")
     */
    private $typeprestataire;

    /**
     * @var ArrayCollection|Rubrique[]
     * @ORM\ManyToMany(targetEntity="Rubrique", mappedBy="prestataires", cascade={"persist"}, fetch="EXTRA_LAZY")
     * @ORM\JoinTable(name="rubrique_prestataire")
     */
    private $rubriques;

    /**
    * @var \Application\Sonata\MediaBundle\Entity\Media
    * @Assert\NotBlank()
    * @ORM\ManyToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"}, fetch="LAZY")
    * @ORM\JoinColumn(name="media_id", referencedColumnName="id")
    */
    protected $media;

   /**
     * @var User
     *
     * @ORM\OneToOne(targetEntity="User", cascade={"all"}, mappedBy="prestataire")
     */
    protected $user;

    /**
     * @var Groupe $prestataireGroup
     *
     * @ORM\ManyToOne(targetEntity="Groupe", cascade={"persist", "remove"}, inversedBy="prestataires")
     */
    private $prestataireGroup;

    /**
     * @var ArrayCollection|Amap[]
     * @ORM\ManyToMany(targetEntity="Groupeprestataire", mappedBy="prestataires", cascade={"persist"}, fetch="EXTRA_LAZY")
     * @ORM\JoinTable(name="groupes_prestataires")
     */
    private $groupeprestataires;


    public function __construct()
    {
        $this->users = new ArrayCollection();
        $this->groupeprestataires = new ArrayCollection();
    }

    /**
     * @return mixed
     */
    public function getId(): int
    {
        return $this->id;
    }

    /**
     * @return string
     */
    public function getRaison(): string
    {
        return $this->raison;
    }

    /**
     * @param string $raison
     * @return Prestataire
     */
    public function setRaison(string $raison)
    {
        $this->raison = $raison;
        return $this;
    }

    /**
     * @return string
     */
    public function getMetier(): string
    {
        return $this->metier;
    }

    /**
     * @param string $metier
     * @return Prestataire
     */
    public function setMetier(string $metier)
    {
        $this->metier = $metier;
        return $this;
    }

    /**
     * @return null|string
     */
    public function getStatut(): ?string
    {
        return $this->statut;
    }

    /**
     * @param null|string $statut
     * @return Prestataire
     */
    public function setStatut(?string $statut)
    {
        $this->statut = $statut;
        return $this;
    }

    /**
     * @return null|string
     */
    public function getResponsable(): ?string
    {
        return $this->responsable;
    }

    /**
     * @param null|string $responsable
     * @return Prestataire
     */
    public function setResponsable(?string $responsable)
    {
        $this->responsable = $responsable;
        return $this;
    }

    /**
     * @return string
     */
    public function getIban(): string
    {
        return $this->iban;
    }

    /**
     * @param string $iban
     * @return Prestataire
     */
    public function setIban(string $iban)
    {
        $this->iban = $iban;
        return $this;
    }

    /**
     * @return string
     */
    public function getSiret(): string
    {
        return $this->siret;
    }

    /**
     * @param string $siret
     * @return Prestataire
     */
    public function setSiret(string $siret)
    {
        $this->siret = $siret;
        return $this;
    }

    /**
     * @return null|string
     */
    public function getWeb(): ?string
    {
        return $this->web;
    }

    /**
     * @param null|string $web
     * @return Prestataire
     */
    public function setWeb(?string $web)
    {
        $this->web = $web;
        return $this;
    }

    /**
     * @return bool
     */
    public function isAccept(): bool
    {
        return $this->accept;
    }

    /**
     * @param bool $accept
     * @return Prestataire
     */
    public function setAccept(bool $accept)
    {
        $this->accept = $accept;
        return $this;
    }

    /**
     * @return bool
     */
    public function isPartenaire(): bool
    {
        return $this->partenaire;
    }

    /**
     * @param bool $partenaire
     * @return Prestataire
     */
    public function setPartenaire(bool $partenaire)
    {
        $this->partenaire = $partenaire;
        return $this;
    }

    /**
     * @return User
     */
    public function getUser(): User
    {
        return $this->user;
    }

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

    /**
     * @param null|Groupe $prestataireGroup
     * @return $this
     */
    public function setPrestataireGroup(?Groupe $prestataireGroup)
    {
        $this->prestataireGroup = $prestataireGroup;
        return $this;
    }

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

    /**
    * Get typeprestataire
    * @return
    */
    public function getTypeprestataire()
    {
        return $this->typeprestataire;
    }

    /**
    * Set typeprestataire
    * @return $this
    */
    public function setTypeprestataire($typeprestataire)
    {
        $this->typeprestataire = $typeprestataire;
        return $this;
    }

    /**
     * @return Rubrique[]|ArrayCollection
     */
    public function getRubriques()
    {
        return $this->rubriques;
    }

    /**
     * @param Rubrique $rubrique
     * @return $this
     */
    public function addRubrique(Rubrique $rubrique)
    {
        if (!$this->rubriques->contains($rubrique)) {
            $this->rubriques[] = $rubrique;
            $rubrique->addPrestataire($this);
        }
        return $this;
    }

    /**
     * @param Rubrique $rubrique
     * @return $this
     */
    public function removeRubrique(Rubrique $rubrique)
    {
        if ($this->rubriques->contains($rubrique)) {
            $this->rubriques->removeElement($rubrique);
            $rubrique->removePrestataire($this);
        }
        return $this;
    }

    /**
     * @return Amap[]|ArrayCollection
     */
    public function getGroupeprestataires()
    {
        return $this->groupeprestataires;
    }

    /**
     * @param Amap $amap
     * @return $this
     */
    public function addGroupeprestataire(Groupeprestataire $groupeprestataire)
    {
        if (!$this->groupeprestataires->contains($groupeprestataire)) {
            $this->groupeprestataires[] = $groupeprestataire;
            $groupeprestataire->addPrestataire($this);
        }
        return $this;
    }

    /**
     * @param Amap $amap
     * @return $this
     */
    public function removeGroupeprestataire(Groupeprestataire $groupeprestataires)
    {
        if ($this->groupeprestataires->contains($groupeprestataire)) {
            $this->groupeprestataires->removeElement($groupeprestataire);
            $groupeprestataire->removePrestataire($this);
        }
        return $this;
    }

    /**
    * Get horaires
    * @return string Horaires
    */
    public function getHoraires(): ?string
    {
        return $this->horaires;
    }

    /**
    * Set horaires
    * @return $this
    */
    public function setHoraires($horaires): self
    {
        $this->horaires = $horaires;
        return $this;
    }

    /**
    * Get media
    * @return
    */
    public function getMedia()
    {
        return $this->media;
    }

    /**
    * Set media
    * @return $this
    */
    public function setMedia($media)
    {
        $this->media = $media;
        return $this;
    }

    public function __toString(): string
    {
        return ($this->raison?$this->raison:($this->getUser()?$this->getUser()->getFullname():'Prestataire '.$this->getId()));
    }
}