It would be painful to always have to check if our findById() method had returned null so we're going to take an idea from Laravel.
We'll have a findOrFail() method which calls findById() for us and throws an Exception if null is returned but returns the post if it is present.
2 comments