Created
April 14, 2020 10:08
-
-
Save fjugaldev/56b46c36930fce285b4f10ae0c61abc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Board.php | |
* | |
* Board Entity | |
* | |
* @category Entity | |
* @package MyKanban | |
* @author Francisco Ugalde | |
* @copyright 2018 www.franciscougalde.com | |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 | |
*/ | |
namespace App\Entity; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use Doctrine\ORM\Mapping as ORM; | |
use DateTime; | |
use JMS\Serializer\Annotation as Serializer; | |
/** | |
* Board | |
* | |
* @ORM\Table(name="board") | |
* @ORM\Entity(repositoryClass="App\Repository\BoardRepository") | |
* @ORM\HasLifecycleCallbacks() | |
*/ | |
class Board | |
{ | |
/** | |
* @ORM\Column(name="id", type="integer") | |
* @ORM\Id() | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** | |
* @ORM\Column(name="name", type="string", length=150) | |
*/ | |
protected $name; | |
/** | |
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="boards") | |
* @ORM\JoinColumn(name="user_id", referencedColumnName="id") | |
* @Serializer\Exclude() | |
*/ | |
protected $user; | |
/** | |
* @ORM\Column(name="created_at", type="datetime") | |
*/ | |
protected $createdAt; | |
/** | |
* @ORM\Column(name="updated_at", type="datetime") | |
*/ | |
protected $updatedAt; | |
/** | |
* @ORM\OneToMany(targetEntity="App\Entity\Task", mappedBy="board") | |
*/ | |
protected $tasks; | |
public function __construct() | |
{ | |
$this->tasks = new ArrayCollection(); | |
} | |
/** | |
* @return mixed | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* @return mixed | |
*/ | |
public function getName() | |
{ | |
return $this->name; | |
} | |
/** | |
* @param mixed $name | |
* @return self | |
*/ | |
public function setName($name) | |
{ | |
$this->name = $name; | |
return $this; | |
} | |
/** | |
* @return mixed | |
*/ | |
public function getUser() | |
{ | |
return $this->user; | |
} | |
/** | |
* @param mixed $user | |
* @return self | |
*/ | |
public function setUser($user) | |
{ | |
$this->user = $user; | |
return $this; | |
} | |
/** | |
* @return mixed | |
*/ | |
public function getCreatedAt() | |
{ | |
return $this->createdAt; | |
} | |
/** | |
* @param mixed $createdAt | |
* @return self | |
*/ | |
public function setCreatedAt($createdAt) | |
{ | |
$this->createdAt = $createdAt; | |
return $this; | |
} | |
/** | |
* @return mixed | |
*/ | |
public function getUpdatedAt() | |
{ | |
return $this->updatedAt; | |
} | |
/** | |
* @param mixed $updatedAt | |
* @return self | |
*/ | |
public function setUpdatedAt($updatedAt) | |
{ | |
$this->updatedAt = $updatedAt; | |
return $this; | |
} | |
/** | |
* @ORM\PrePersist | |
* @ORM\PreUpdate | |
*/ | |
public function updatedTimestamps() | |
{ | |
$dateTimeNow = new DateTime('now'); | |
$this->setUpdatedAt($dateTimeNow); | |
if ($this->getCreatedAt() === null) { | |
$this->setCreatedAt($dateTimeNow); | |
} | |
} | |
/** | |
* @return mixed | |
*/ | |
public function getTasks() | |
{ | |
return $this->tasks; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment