簡(jiǎn)單的解決方法是使用 ArrayObject 存取器方法:
$this['attributes'] = ['x' => 'y']; $stuff = $this['attributes'];
注意:仍然需要定義「attributes」轉(zhuǎn)換才能以陣列形式存取底層 jsonb 欄位:
protected $casts = [ 'attributes' => AsArrayObject::class ];