src/Post/Post.php
public function newFromBuilder($attributes = [], $connection = null)
    {
        $attributes = (array) $attributes;

        if (! empty($attributes['type'])
            && isset(static::$models[$attributes['type']])
            && class_exists($class = static::$models[$attributes['type']])
        ) {
            /** @var Post $instance */
            $instance = new $class;
            $instance->exists = true;
            $instance->setRawAttributes($attributes, true);
            $instance->setConnection($connection ?: $this->connection);

            return $instance;
        }

        return parent::newFromBuilder($attributes, $connection);
    }
public function newFromBuilder($attributes = [], $connection = null)
    {
        $attributes = (array) $attributes;

        if (! empty($attributes['type'])
            && isset(static::$models[$attributes['type']])
            && class_exists($class = static::$models[$attributes['type']])
        ) {
            /** @var Post $instance */
            $instance = new $class;
            $instance->exists = true;
            $instance->setRawAttributes($attributes, true);
            $instance->setConnection($connection ?: $this->connection);

            return $instance;
        }

        return parent::newFromBuilder($attributes, $connection);
    }
public function newFromBuilder ( $ attributes = [ ] , $ connection = null ) { $ attributes = ( array ) $ attributes ; if ( ! empty ( $ attributes [ 'type' ] ) && isset ( static :: $ models [ $ attributes [ 'type' ] ] ) && class_exists ( $ class = static :: $ models [ $ attributes [ 'type' ] ] ) ) { /** @var Post $instance */ $ instance = new $ class ; $ instance -> exists = true ; $ instance -> setRawAttributes ( $ attributes , true ) ; $ instance -> setConnection ( $ connection ? : $ this -> connection ) ; return $ instance ; } return parent :: newFromBuilder ( $ attributes , $ connection ) ; }
Create a new model instance according to the post's type.

@param array $attributes
@param string|null $connection
@return static|object
Create a new model instance according to the post s type .