Answer the question
In order to leave comments, you need to log in
Which is better to use $model->create() or $model->save()?
I know that create te wrapper save .
public static function create(array $attributes = [])
{
$model = new static($attributes);
$model->save();
return $model;
}
Answer the question
In order to leave comments, you need to log in
I find it's better and easier to use create() as this method allows for quick data entry and works well with data validation.
For example:
Agree, this is much faster than, for example:
$article = new Article();
$article->title = $request->input('title');
$article->category_id = $request->input('category_id');
$article->content = $request->input('content');
$article->save();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question