Files
php-qml/framework/php/src/Maker/templates/Entity.tpl.php
T

72 lines
1.2 KiB
PHP
Raw Normal View History

<?= "<?php\n" ?>
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use PhpQml\Bridge\Attribute\BridgeResource;
<?php if ($use_uuid): ?>
use Symfony\Component\Uid\Uuid;
<?php endif; ?>
#[ORM\Entity]
#[BridgeResource(name: '<?= $resource ?>')]
class <?= $entity_short ?>
{
<?php if ($use_uuid): ?>
#[ORM\Id]
#[ORM\Column(type: 'uuid', unique: true)]
private Uuid $id;
<?php else: ?>
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
<?php endif; ?>
#[ORM\Column(length: 255)]
private string $title = '';
#[ORM\Column]
private bool $done = false;
<?php if ($use_uuid): ?>
public function __construct()
{
$this->id = Uuid::v7();
}
public function getId(): Uuid
{
return $this->id;
}
<?php else: ?>
public function getId(): ?int
{
return $this->id;
}
<?php endif; ?>
public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): void
{
$this->title = $title;
}
public function isDone(): bool
{
return $this->done;
}
public function setDone(bool $done): void
{
$this->done = $done;
}
}