Beispiel #1
0
 /**
  * Make an instance of the model.
  *
  * @param string $model The model class name.
  * @param array  $attr  The model attributes.
  * @param bool   $save  Are we saving, or just creating an instance?
  *
  * @return object
  */
 private function make($model, array $attr, $save)
 {
     $group = $this->getGroup($model);
     $class = $this->getModelClass($model, $group);
     $object = $this->makeClass($class);
     // Make the object as saved so that other generators persist correctly
     if ($save) {
         Arr::add($this->pending, $object);
     }
     // Get the group specific factory attributes
     if ($group) {
         $attr = array_merge($attr, $this->getFactoryAttrs($model));
     }
     // Get the factory attributes for that model
     $attributes = $this->attributesFor($object, $attr);
     foreach ($attributes as $name => $value) {
         $this->setAttribute($object, $name, $value);
     }
     return $object;
 }