【发布时间】:2017-02-15 08:57:53
【问题描述】:
我在数据库中有 3 个不同的字段:city、state、country。如何在 Eloquent 中定义另一个属性以从这 3 个字段中返回一个字符串?
第一种方法,但它不起作用:
protected $address = "";
public function getAddress() : string {
return $this->city . $this->state . " - " . $this->country;
}
【问题讨论】: