Reputation: 24061
I perform various eloquent statements throughout my app. eg:
User::find($id)->update($data);
Or:
User::create($data);
Or:
User::paginate(10);
I presume the best way to tackle potential errors is to use try/catch? If so, what should I be catching for eloquent errors?
Upvotes: 3
Views: 192
Reputation: 163788
There is findOrFail()
method which will be helpful in some situations. But what kind of errors at runtime do you expect from paginate()
, update()
, create()
?
During development Laravel will throw an exception when something is wrong with your model, like MassAssignmentException
when some property you're trying to update is missing in $fillable
.
Upvotes: 3