using item() breaks if relationship doesnt exist collection() doesnt break?
Open
- Dominant language
- PHP
- Stars
- 9.4k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
so if in my transformer i do something like
```
public function includeTestimonials(Entity $item)
{
return $this->collection($item->testimonials, new TestimonialTransformer, true);
}
```
this works even if testimonials is missing
but
```
public function includeShop(Entity $item)
{
if ( $item->shop )
return $this->item($item->shop, new ShopTransformer, true);
}
```
i have to add in an if check otherwise this gives me an error shop entity expected null given? i dont want to be adding lots of if statements..
Contributor guide
Assessment
This issue has not been assessed yet.