私はデータベースに3種類のフィールド、city
,state
、country
を持っています。どのように私は3つのフィールドから1つの文字列を返すEloquentの別の属性を定義するのですか?Eloquentでカスタム属性を定義する
最初のアプローチが、それは動作しません:
protected $address = "";
public function getAddress() : string {
return $this->city . $this->state . " - " . $this->country;
}
これは動作します!!!!!!! – ln9187