Prestataire.php 10.5 KB
Newer Older
Julien Jorry committed
1 2 3 4 5 6 7 8 9 10
<?php

namespace App\Entity;

use App\Entity\EntityTrait\EnablableEntityTrait;
use App\Entity\EntityTrait\GeolocEntityTrait;
use App\Entity\EntityTrait\HasCompteEntity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
11
use Gedmo\Mapping\Annotation\Slug;
12
use Gedmo\Timestampable\Traits\TimestampableEntity;
Julien Jorry committed
13 14 15
use Symfony\Component\Validator\Constraints as Assert;

/**
16
 * @ORM\Entity(repositoryClass="App\Repository\PrestataireRepository")
Julien Jorry committed
17 18 19 20 21
 * @ORM\Table(name="prestataire")
 */
class Prestataire
{
    use EnablableEntityTrait,
22
        TimestampableEntity,
Julien Jorry committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
        GeolocEntityTrait,
        HasCompteEntity;

    /**
     * @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;

42 43 44 45 46 47 48
    /**
     * @var string|null
     *
     * @ORM\Column(type="text", nullable=true)
     */
    private $description;

49 50 51 52 53 54 55 56
    /**
     * @var string|null
     *
     * @Gedmo\Slug(fields={"raison"})
     * @ORM\Column(length=100, unique=true)
     */
    protected $slug;

Julien Jorry committed
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
    /**
     * @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;

106 107 108 109 110 111 112 113
    /**
     * @var bool
     *
     * @ORM\Column(name="partenaire", type="boolean", nullable=false)
     */
    private $partenaire = false;


Julien Jorry committed
114 115 116 117 118 119 120
    /**
     * @var null|string (champ libre)
     *
     * @ORM\Column(name="horaires", type="string", length=255, nullable=true)
     */
    private $horaires;

Julien Jorry committed
121 122 123 124 125 126 127 128
    /**
     * @var TypePrestataire
     *
     * @ORM\ManyToOne(targetEntity="TypePrestataire", cascade={"persist"}, inversedBy="prestataires")
     */
    private $typeprestataire;

    /**
Julien Jorry committed
129 130 131
     * @var ArrayCollection|Rubrique[]
     * @ORM\ManyToMany(targetEntity="Rubrique", mappedBy="prestataires", cascade={"persist"}, fetch="EXTRA_LAZY")
     * @ORM\JoinTable(name="rubrique_prestataire")
Julien Jorry committed
132
     */
Julien Jorry committed
133 134 135 136 137
    private $rubriques;

    /**
    * @var \Application\Sonata\MediaBundle\Entity\Media
    * @ORM\ManyToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"}, fetch="LAZY")
138
    * @ORM\JoinColumn(name="media_id", referencedColumnName="id", nullable=true)
Julien Jorry committed
139 140
    */
    protected $media;
Julien Jorry committed
141 142 143 144

   /**
     * @var User
     *
145
     * @ORM\OneToOne(targetEntity="User", cascade={"all"}, mappedBy="prestataire", fetch="LAZY")
Julien Jorry committed
146 147 148 149
     */
    protected $user;

    /**
150
     * @var Groupe $groupe
Julien Jorry committed
151
     *
152
     * @ORM\ManyToOne(targetEntity="App\Entity\Groupe", inversedBy="prestataires")
Julien Jorry committed
153
     */
154
    private $groupe;
Julien Jorry committed
155 156

    /**
157 158
     * @var ArrayCollection|Amap/Marché[]
     * @ORM\ManyToMany(targetEntity="Groupeprestataire", mappedBy="prestataires", fetch="EXTRA_LAZY")
Julien Jorry committed
159
     * @ORM\JoinTable(name="groupes_prestataires")
Julien Jorry committed
160 161 162 163 164 165 166
     */
    private $groupeprestataires;

    public function __construct()
    {
        $this->users = new ArrayCollection();
        $this->groupeprestataires = new ArrayCollection();
167
        $this->rubriques = new ArrayCollection();
Julien Jorry committed
168 169 170 171 172 173 174 175 176 177 178 179 180
    }

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

    /**
     * @return string
     */
181
    public function getRaison(): ?string
Julien Jorry committed
182 183 184 185 186 187 188 189 190 191 192 193 194 195
    {
        return $this->raison;
    }

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

196 197 198 199 200 201 202 203 204 205 206
    public function getSlug(): ?string
    {
        return $this->slug;
    }

    public function setSlug(?string $slug)
    {
        $this->slug = $slug;
        return $this;
    }

207 208 209 210 211 212 213 214 215 216 217
    public function setDescription(?string $description)
    {
        $this->description = $description;
        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

Julien Jorry committed
218 219 220
    /**
     * @return string
     */
221
    public function getMetier(): ?string
Julien Jorry committed
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
    {
        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
     */
275
    public function getIban(): ?string
Julien Jorry committed
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
    {
        return $this->iban;
    }

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

    /**
     * @return string
     */
293
    public function getSiret(): ?string
Julien Jorry committed
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
    {
        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
     */
365
    public function getUser(): ?User
Julien Jorry committed
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
    {
        return $this->user;
    }

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

    /**
381
     * @param null|Groupe $groupe
Julien Jorry committed
382 383
     * @return $this
     */
384
    public function setGroupe(?Groupe $groupe)
Julien Jorry committed
385
    {
386
        $this->groupe = $groupe;
Julien Jorry committed
387 388 389 390 391 392
        return $this;
    }

    /**
     * @return null|Groupe
     */
393
    public function getGroupe(): ?Groupe
Julien Jorry committed
394
    {
395
        return $this->groupe;
Julien Jorry committed
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
    }

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

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

Julien Jorry committed
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
    /**
     * @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;
    }

Julien Jorry committed
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
    /**
     * @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;
    }
Julien Jorry committed
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524

    /**
    * 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
    {
525
        return ($this->raison?$this->raison:($this->getUser()?$this->getUser()->getFullname():'Prestataire'));
Julien Jorry committed
526
    }
Julien Jorry committed
527
}