I have some common fields in almost all tables. So I created an AbstractEntity
class where I can add fields that are in common.
/**
* @MappedSuperclass
*/
abstract class AbstractEntity
{
/**
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer", options={"unsigned"=true})
*/
protected int $id;
/**
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
protected string $createdAt;
public function getId(): int
{
return $this->id;
}
public function createdAt(): string
{
return $this->createdAt;
}
public function setShopLocale(string $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
}
Now, I extend Abstractclass in other EntityClass
class Random extends AbstractEntity
{
}
I am getting following error message when I try to insert record.
Class "App\Entity\Admin\Random" sub class of "App\Entity\Admin\AbstractEntity" is not a valid entity or mapped super class.