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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With