Defining Entities
<?php
declare(strict_types=1);
namespace App\Entities;
use Cycle\ActiveRecord\ActiveRecord;
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
#[Entity(table: 'users')]
class User extends ActiveRecord
{
#[Column(type: 'bigInteger', primary: true, typecast: 'int')]
private int $id;
#[Column(type: 'string')]
private string $name;
#[Column(type: 'string', unique: true)]
private string $email;
public function __construct(string $name, string $email)
{
$this->name = $name;
$this->email = $email;
}
public function id(): int
{
return $this->id;
}
public function name(): string
{
return $this->name;
}
public function changeName(string $name): void
{
$this->name = $name;
}
public function email(): string
{
return $this->email;
}
public function changeEmail(string $email): void
{
$this->email = $email;
}
}๐ Entity Annotations
Last updated