code: public function toArray()
      {
          return function ($next, $attributes) {
              unset($attributes['meta_attributes'], $attributes['metaAttributes']);
  
              $attributes = array_merge($attributes, $this->getMetaAttributesArray());
  
              return $next($attributes);
          };
      }
docs: Register hook on toArray method.
  
  @return \Closure