Prestataire.php 10.4 KB
Newer Older
Julien Jorry committed
1 2 3 4 5 6 7
<?php

namespace App\Entity;

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

/**
18
 * @ORM\Entity(repositoryClass="App\Repository\PrestataireRepository")
Julien Jorry committed
19 20 21 22 23
 * @ORM\Table(name="prestataire")
 */
class Prestataire
{
    use EnablableEntityTrait,
24
        TimestampableEntity,
Julien Jorry committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
        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;

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

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

Julien Jorry committed
59 60 61
    /**
     * @var string
     *
62
     * @ORM\Column(name="metier", type="string", length=100, nullable=true)
Julien Jorry committed
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
     */
    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;

Julien Jorry committed
108 109 110 111 112 113 114
    /**
     * @var null|string (champ libre)
     *
     * @ORM\Column(name="horaires", type="string", length=255, nullable=true)
     */
    private $horaires;

Julien Jorry committed
115 116 117 118 119 120 121 122
    /**
     * @var TypePrestataire
     *
     * @ORM\ManyToOne(targetEntity="TypePrestataire", cascade={"persist"}, inversedBy="prestataires")
     */
    private $typeprestataire;

    /**
Julien Jorry committed
123 124 125
     * @var ArrayCollection|Rubrique[]
     * @ORM\ManyToMany(targetEntity="Rubrique", mappedBy="prestataires", cascade={"persist"}, fetch="EXTRA_LAZY")
     * @ORM\JoinTable(name="rubrique_prestataire")
Julien Jorry committed
126
     */
Julien Jorry committed
127 128 129 130 131
    private $rubriques;

    /**
    * @var \Application\Sonata\MediaBundle\Entity\Media
    * @ORM\ManyToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"}, fetch="LAZY")
132
    * @ORM\JoinColumn(name="media_id", referencedColumnName="id", nullable=true)
Julien Jorry committed
133 134
    */
    protected $media;
Julien Jorry committed
135 136 137 138

   /**
     * @var User
     *
139
     * @ORM\OneToOne(targetEntity="User", cascade={"all"}, mappedBy="prestataire", fetch="LAZY")
Julien Jorry committed
140 141 142 143
     */
    protected $user;

    /**
144
     * @var Groupe $groupe
Julien Jorry committed
145
     *
Julien Jorry committed
146
     * @ORM\ManyToOne(targetEntity="Groupe", inversedBy="prestataires")
147
     * @Assert\NotBlank
Julien Jorry committed
148
     */
149
    private $groupe;
Julien Jorry committed
150 151

    /**
Julien Jorry committed
152 153 154
     * AMAP / Marché
     * @var ArrayCollection|Groupeprestataire[]
     * @ORM\ManyToMany(targetEntity="Groupeprestataire", cascade={"persist"}, mappedBy="prestataires")
Julien Jorry committed
155
     * @ORM\JoinTable(name="groupes_prestataires")
Julien Jorry committed
156 157 158 159 160 161 162
     */
    private $groupeprestataires;

    public function __construct()
    {
        $this->users = new ArrayCollection();
        $this->groupeprestataires = new ArrayCollection();
163
        $this->rubriques = new ArrayCollection();
Julien Jorry committed
164 165 166 167 168 169 170 171 172 173 174 175 176
    }

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

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

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

192 193 194 195 196 197 198 199 200 201 202
    public function getSlug(): ?string
    {
        return $this->slug;
    }

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

203 204 205 206 207 208 209 210 211 212 213
    public function setDescription(?string $description)
    {
        $this->description = $description;
        return $this;
    }

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

Julien Jorry committed
214 215 216
    /**
     * @return string
     */
217
    public function getMetier(): ?string
Julien Jorry committed
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
    {
        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
     */
271
    public function getIban(): ?string
Julien Jorry committed
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
    {
        return $this->iban;
    }

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

    /**
     * @return string
     */
289
    public function getSiret(): ?string
Julien Jorry committed
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
    {
        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 User
     */
343
    public function getUser(): ?User
Julien Jorry committed
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
    {
        return $this->user;
    }

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

    /**
359
     * @param null|Groupe $groupe
Julien Jorry committed
360 361
     * @return $this
     */
362
    public function setGroupe(?Groupe $groupe)
Julien Jorry committed
363
    {
364
        $this->groupe = $groupe;
Julien Jorry committed
365 366 367 368 369 370
        return $this;
    }

    /**
     * @return null|Groupe
     */
371
    public function getGroupe(): ?Groupe
Julien Jorry committed
372
    {
373
        return $this->groupe;
Julien Jorry committed
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
    }

    /**
    * 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
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
    /**
     * @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
429 430 431 432 433 434 435 436
    /**
     * @return Amap[]|ArrayCollection
     */
    public function getGroupeprestataires()
    {
        return $this->groupeprestataires;
    }

Julien Jorry committed
437 438 439 440 441 442 443 444 445 446
    /**
     * @param Amap[]|ArrayCollection
     * @return this
     */
    public function setGroupeprestataires($groupeprestataires)
    {
        $this->groupeprestataires = $groupeprestataires;
        return $this;
    }

Julien Jorry committed
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
    /**
     * @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
472 473 474 475 476 477 478 479 480 481 482 483 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

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