LMongo\Eloquent\Relations\HasOneOrMany::create PHP Method

create() public method

Create a new instance of the related model.
public create ( array $attributes ) : Model
$attributes array
return LMongo\Eloquent\Model
    public function create(array $attributes)
    {
        $foreign = array($this->foreignKey => new MongoID($this->parent->getKey()));
        // Here we will set the raw attributes to avoid hitting the "fill" method so
        // that we do not have to worry about a mass accessor rules blocking sets
        // on the models. Otherwise, some of these attributes will not get set.
        $instance = $this->related->newInstance();
        $instance->setRawAttributes(array_merge($attributes, $foreign));
        $instance->save();
        return $instance;
    }