Illuminate\Database\Eloquent\Model::forceCreate PHP Méthode

forceCreate() public static méthode

Save a new model and return the instance. Allow mass-assignment.
public static forceCreate ( array $attributes ) : static
$attributes array
Résultat static
    public static function forceCreate(array $attributes)
    {
        return static::unguarded(function () use($attributes) {
            return (new static())->create($attributes);
        });
    }

Usage Example

 /**
  * @param array $data
  * @param bool  $force
  * @return mixed
  * @throws RepositoryException
  */
 public function create(array $data, $force = true)
 {
     $model = $force ? $this->model->forceCreate($data) : $this->model->create($data);
     $this->cleanRepository();
     return $model;
 }
Model