Laravel syntax question with child relations for includes etc.
- Dominant language
- PHP
- Stars
- 163
- Forks
- 70
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to include the address in the company
It's fine on the singular model.
`/api/v1/companies/22?includes%5B%5D=address`
```php
$resourceOptions = $this->parseResourceOptions();
$query = $this->project::query();
$this->applyResourceOptions($query, $resourceOptions);
$result = $query->find($id);
```
But I cant figure out how to change the syntax when calling a child.
`/api/v1/projects/578/company?includes%5B%5D=address`
```php
$result = $this->project::find($id)->company;
```
Contributor guide
Research direction
Start by comparing the working `/api/v1/companies/22?includes[]=address` request with `/api/v1/projects/578/company?includes[]=address` and the two query snippets in the issue. No source file or test is named; done should be a documented or tested way for the child-company response to include its address.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100