问题描述
我想在名为“ Book”的实体中为名为“ status”的属性设置默认值:
<?PHP
namespace App\Entity;
/**
* @ORM\Entity(repositoryClass=BookingRepository::class)
*/
class Booking
{
const STATUS = [
0 => 'Pending',1 => 'Canceled',2 => 'Confirmed',3 => 'Approved',];
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string",length=255,options={"default": "Pending"})
*/
private $status = self::STATUS[0];
public function getId(): ?int
{
return $this->id;
}
public function getStatus(): ?string
{
return $this->status;
}
public function getBookingStatus(): ?string
{
return self::STATUS[$this->status];
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
}
我用键/值声明了STATUS数组,以定义选择或枚举类型,我想将$ status的默认值设置为Pending!是我做对的事情还是需要做其他事情?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)