use App\Models\User; $user = User::findOrFail(1);
use App\Models\Post; $post = Post::findOrFail($id);In this example, the code retrieves a post with an ID of `$id` from the `posts` table, or throws an exception if the post is not found. In both cases, the `findOrFail` method is a convenient way to retrieve a specific model instance by its primary key without having to manually check if the model exists.