The findOrFail method also accepts a list of ids. If any of these ids are not found, then it "fails".
Nice if you need to retrieve a specific set of models and don't want to have to check that the count you got was the count you expected
User::create(['id' => 1]);User::create(['id' => 2]);User::create(['id' => 3]); // Retrieves the user...$user = User::findOrFail(1); // Throws a 404 because the user doesn't exist...User::findOrFail(99); // Retrieves all 3 users...$users = User::findOrFail([1, 2, 3]); // Throws because it is unable to find *all* of the usersUser::findOrFail([1, 2, 3, 99]);
Tip given by @timacdonald87
Enjoyed This Tip?
Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.
Recent Courses on Laravel Daily
AI Agents/IDEs for Laravel: May 2026 (Claude Code, Codex, OpenCode, etc)
7 lessons
52 min
Roles and Permissions in Laravel 13
14 lessons
57 min
[FREE] Laravel 13 for Beginners: 3 Demo Projects
5 lessons
29 min