[ad_1]
I am trying to exclude a few relations from my API call.
Right now I’m returning the records as following:
return response()->json(Ticket::where('status_id', '!=', 5)->get());
In the ticket model I have a belongsTo relation with customer.
In the customer model I have a hasOne relation with Address.
Now, I have included the address in the customer model, and the customer in the ticket model usin $with.
I want to get the customer with the ticket, but not the address. I tried using the without
function as followed: Ticket::where('status_id', '!=', 5)->without(['customer.address'])->get()
.
This is not working, however the following does work: Ticket::where('status_id', '!=', 5)->without(['customer'])->get()
I do get the ticket without any relations.
I assumed the first function would work, considering this also works in the with() function, but it does not.
[ad_2]