---
title: "Discussion on \"Understanding `whenLoaded()` and `when()` in Laravel API Resources\" | Hashnode"
description: "Discussion on \"Understanding `whenLoaded()` and `when()` in Laravel API Resources\". SummeryThis blog post explains how to use whenLoaded() and when() in Laravel API Resources to conditionally include data in API responses. whenLoaded() only includes related data if it's been eager-loaded, preventing performance issues, while when() ..."
url: "https://hashnode.com/posts/understanding-whenloaded-and-when-in-laravel-api-resources/67db9b4367601889c0ff8db7"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Understanding \`whenLoaded()\` and \`when()\` in Laravel API Resources](https://blog.debjit.in/understanding-whenloaded-and-when-in-laravel-api-resources?utm_source=hashnode&utm_medium=feed)

SummeryThis blog post explains how to use whenLoaded() and when() in Laravel API Resources to conditionally include data in API responses. whenLoaded() only includes related data if it's been eager-loaded, preventing performance issues, while when() ...

Mar 20, 2025 · 5 min read · blog.debjit.in  
Updated Mar 28, 2025  
Read the article

-   [#laravel](https://hashnode.com/tag/laravel)
-   [#apis](https://hashnode.com/tag/apis)
-   [#rest-api](https://hashnode.com/tag/rest-api)

## Written by

[Debjit Biswas](https://hashnode.com/@debjit)

@debjit · West Bengal, India

  
[View profile](https://hashnode.com/@debjit)

Full Stack Web Developer

Developer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
