create() публичный Метод

Creates and saves a model.
public create ( string $name, array $attr = [] ) : object
$name string The model definition name.
$attr array The model attributes.
Результат object
Пример #1
0
 /**
  * Create an instance of the model.
  *
  * This model will be automatically saved to the database if the model we
  * are generating it for has been saved (the create function was used).
  *
  * @param string $name The model definition name.
  *
  * @return object
  */
 private function factory($name)
 {
     if ($this->factoryMuffin->isPendingOrSaved($this->model)) {
         return $this->factoryMuffin->create($name);
     }
     return $this->factoryMuffin->instance($name);
 }
Пример #2
0
 /**
  * Generates and saves a record,.
  *
  * ```php
  * $I->have('User'); // creates user
  * $I->have('User', ['is_active' => true]); // creates active user
  * ```
  *
  * Returns an instance of created user.
  *
  * @param $name
  * @param array $extraAttrs
  *
  * @return object
  */
 public function have($name, array $extraAttrs = [])
 {
     return $this->factoryMuffin->create($name, $extraAttrs);
 }