Now imagine the user clicking on the property to choose the apartment. Inside the property view, we need to show the full list of available apartments, with their facilities:

The Facility model will be a new thing in this lesson.
Goals of This Lesson
- Build Facility DB/relationship structure
- Show facilities in the new Show Property endpoint
By the end of this lesson, we will have this list of facilities showing in Postman:

Facilities: DB Structure
An obvious question: what are those facilities, and what are the different options and categories for them? There could be dozens or even hundreds of various facilities.
I've found the answer to this question while browsing the mobile version of Booking.com, which showed the apartment facilities in a well-structured way:...
Are you sure this about this line?
From what I remember in my testing yes it was NULL. Can you explain your thought why this is wrong?
Sorry, You right, the test comes success
I have carefully read the guide you published on property listings and I have a question regarding the invoke method in the PropertyController. In the section where data is loaded using the load method, I noticed that the load method is called twice for the apartments.facilities relationship. I'm wondering why it is necessary to reload the relationship at this stage, as it seems that the relationship is already included in the $property object in the first load('apartments.facilities') call. Could you please explain why a second load of the same relationship is being performed?
I read in the guide that it mentions overriding the values of apartments, but I'm not clear on how this is connected to the second load of the relationship. Could you kindly provide further details on this point?**
You're probably right, we don't need to load it the second time. I will update the tutorial, great catch!
When setup migration for facilities table, the reason why u re using references('id')->on('facility_categories') instead of using constrained because the table name is not categories. But we can use constrained function and put the table name as first argument like constrained('facility_categories', 'id'), can't we?
Sir, firstly thankyou for this tutorial i'm learning a lot. I followed this guide until i found an error on PropertyShowTest in part :
the error message is "property show loads property correctly. Failed asserting that null is identical to 'Some Facility" i try to debug using dd($response->json()). i notice the facilities field is not exist Although i already load the apartments.facilities relationship on the PropertyController. But when i change $this->whenLoaded('facilities') to $this->facilities (on ApartmentSearchResource), the facilities field exists and the test passes. I spend hours trying to solve this but still no solution yet. Could u help me to solve this? Or what im missing? Thanks
To be honest, I don't remember now as the course has been created a few months ago, and I can't "blindly" debug your situation. Could you please compare your code to the official repository and maybe see what you're missing? Or maybe the error is in the official repository, too? Then let me know. Thanks!
Hi, the problem is when you filter by adults and children in the controller, you only load facilities relationship when you don't send query params.
In the guide, the code is this:
But if you add the facilities relationship into query params, all test pass.
Wow thank you that solve the issue, much appreciated