Create a new instance of the given model.
public newInstance ( array $attributes = [], boolean $exists = false ) : static | ||
$attributes | array | |
$exists | boolean | |
return | static |
$user = new User; $user->name = 'John Smith'; $user->email = 'john@example.com'; $user->save();
$post = Post::newInstance([ 'title' => 'A Blog Post', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'published' => true ]); $post->save();In this example, `newInstance()` is called with an array of attributes for a new Post model. The `save()` method is called to persist the new record to the database. Package Library: PHP Illuminate Database (Eloquent ORM)
public newInstance ( array $attributes = [], boolean $exists = false ) : static | ||
$attributes | array | |
$exists | boolean | |
return | static |