Artisan72
Artisan72

Reputation: 3620

Laravel5: refresh method for eloquent models?

I create a model and save it, using the save() methods, and I do not fill all properties. Mysql will set the assigned default values of the columns.

But the values are not filled after, just the primary keys.

Isn't there a something like "refresh()" method which updates my model instance with the actual data?

Upvotes: 2

Views: 3932

Answers (1)

Joseph Silber
Joseph Silber

Reputation: 220066

  1. Yes. There's a fresh method on the model that does exactly that.
  2. You shouldn't need this. You should add the default values to the $attributes array so that you always have the default values automatically.

Upvotes: 3

Related Questions