Display only some field for relation model #306
Replies: 1 comment
-
ok, found : building: array{id: int, name: string}, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi ,
I don't figure out how to display only some columns for a relational model.
I have a Model (Siteconfig) which has a Building relation with building_id. My request is like this :
$allconfigs = Siteconfig::with(['building:id,name'])->get()
I would like so to display only the id and name for the Building model, I tried this :
* @response array{id: int, building_id: int, building: {id: int}}[]
also this
* @response array{id: int, building_id: int, building: \App\Models\Building}[]
For the last one, it shows me all the fields for the Building model, but I only want id and name showing.
Do you know how to do this ?
Beta Was this translation helpful? Give feedback.
All reactions