🔥 Laravel tip: the sole method
Feb 15, 2022
You can use the sole method to make sure you have one record matching a query.
If the record is not found, it will throw `ModelNotFoundException`.
But, if more than one record is found, it will throw `MultipleRecordsFoundException`
If the record is not found, it will throw `ModelNotFoundException`.
But, if more than one record is found, it will throw `MultipleRecordsFoundException`
![tip-image-0](https://res.cloudinary.com/dpmeu3otn/image/upload/v1666547712/tips/uyrdds31dwyj9hwviiba.jpg)
Other tips:
🔥 Eager loading cheat sheet
Mar 4, 2022