code: public function setAttribute()
      {
          return function ($next, $value, $args) {
              $key = $args->get('key');
  
              if (!$this->hasColumn($key) && $this->allowsMeta($key) && !$this->hasSetMutator($key)) {
                  return $this->setMeta($key, $value);
              }
  
              return $next($value, $args);
          };
      }
docs: Register hook on setAttribute method.
  
  @return \Closure