resq/src/Entity/Partner.php
2019-07-05 07:26:16 +00:00

121 lines
2.3 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")
* @ORM\JoinTable(name="partner_services")
*/
protected $services;
public function __construct()
{
$this->time_open = new DateTime();
$this->time_close = new DateTime();
$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)
{
$this->services->add($service);
return $this;
}
public function clearServices()
{
$this->services->clear();
return $this;
}
public function getServices()
{
$str_services = [];
foreach ($this->services as $service)
$str_services[] = $service->getID();
return $str_services;
}
public function getServicesObjects()
{
return $this->services;
}
}