118 lines
2.2 KiB
PHP
118 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Ramcar\Location;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use DateTime;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="partner")
|
|
*/
|
|
class Partner
|
|
{
|
|
use Location;
|
|
|
|
// unique id
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
protected $id;
|
|
|
|
// name
|
|
/**
|
|
* @ORM\Column(type="string", length=80)
|
|
* @Assert\NotBlank()
|
|
*/
|
|
protected $name;
|
|
|
|
// date created
|
|
/**
|
|
* @ORM\Column(type="datetime")
|
|
*/
|
|
protected $date_create;
|
|
|
|
// user that created the partner
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="partners_created")
|
|
* @ORM\JoinColumn(name="create_user_id", referencedColumnName="id", nullable=true)
|
|
*/
|
|
protected $created_by;
|
|
|
|
// services provided
|
|
/**
|
|
* @ORM\ManyToMany(targetEntity="Service", inversedBy="partners", indexBy="id")
|
|
* @ORM\JoinTable(name="partner_services")
|
|
*/
|
|
protected $services;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->services = new ArrayCollection();
|
|
$this->date_create = new DateTime();
|
|
}
|
|
|
|
public function getID()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function setName($name)
|
|
{
|
|
$this->name = $name;
|
|
return $this;
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function getDateCreate()
|
|
{
|
|
return $this->date_create;
|
|
}
|
|
|
|
public function setCreatedBy(User $created_by)
|
|
{
|
|
$this->created_by = $created_by;
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedBy()
|
|
{
|
|
return $this->created_by;
|
|
}
|
|
|
|
public function addService(Service $service)
|
|
{
|
|
if (!isset($this->services[$service->getID()]))
|
|
unset($this->services[$service->getID()]);
|
|
return $this;
|
|
}
|
|
|
|
public function removeService(Service $service)
|
|
{
|
|
if (isset($this->services[$service->getID()]))
|
|
unset($this->services[$service->getID()]);
|
|
return $this;
|
|
}
|
|
|
|
public function clearServices()
|
|
{
|
|
$this->services->clear();
|
|
return $this;
|
|
}
|
|
|
|
public function getServices()
|
|
{
|
|
return $this->services;
|
|
}
|
|
|
|
}
|