Basic functionality
This commit is contained in:
33
app/model/Database/Entity/Attributes/TCreatedAt.php
Executable file
33
app/model/Database/Entity/Attributes/TCreatedAt.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Entity\Attributes;
|
||||
|
||||
use App\Model\Utils\DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
trait TCreatedAt
|
||||
{
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
* @ORM\Column(type="datetime", nullable=FALSE)
|
||||
*/
|
||||
protected $createdAt;
|
||||
|
||||
public function getCreatedAt(): DateTime
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doctrine annotation
|
||||
*
|
||||
* @ORM\PrePersist
|
||||
* @internal
|
||||
*/
|
||||
public function setCreatedAt(): void
|
||||
{
|
||||
$this->createdAt = new DateTime();
|
||||
}
|
||||
|
||||
}
|
||||
29
app/model/Database/Entity/Attributes/TId.php
Executable file
29
app/model/Database/Entity/Attributes/TId.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Entity\Attributes;
|
||||
|
||||
trait TId
|
||||
{
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @ORM\Column(type="integer", nullable=FALSE)
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @property int $id
|
||||
*/
|
||||
private $id;
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->id = null;
|
||||
}
|
||||
|
||||
}
|
||||
33
app/model/Database/Entity/Attributes/TUpdatedAt.php
Executable file
33
app/model/Database/Entity/Attributes/TUpdatedAt.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Entity\Attributes;
|
||||
|
||||
use App\Model\Utils\DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
trait TUpdatedAt
|
||||
{
|
||||
|
||||
/**
|
||||
* @var DateTime|NULL
|
||||
* @ORM\Column(type="datetime", nullable=TRUE)
|
||||
*/
|
||||
protected $updatedAt;
|
||||
|
||||
public function getUpdatedAt(): ?DateTime
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doctrine annotation
|
||||
*
|
||||
* @ORM\PreUpdate
|
||||
* @internal
|
||||
*/
|
||||
public function setUpdatedAt(): void
|
||||
{
|
||||
$this->updatedAt = new DateTime();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user