簡單的解決方法是使用 ArrayObject 訪問器方法:
$this['attributes'] = ['x' => 'y']; $stuff = $this['attributes'];
注意:仍然需要定義“attributes”轉換才能以數(shù)組形式訪問底層 jsonb 字段:
protected $casts = [ 'attributes' => AsArrayObject::class ];