arcadiaBrand; $xmlIncos = XmlInco::query(); if ($arcadiaBrand) { // * Make sure we are accessing xmlIncos that belongs to our service. $this->authorize('arcadiaBrandBelongsToService', $arcadiaBrand); $xmlIncos->whereHas('arcadiaBrands', function ($q) use ($arcadiaBrand) { $q->whereId($arcadiaBrand->id); }); } return XmlIncoResource::collection($xmlIncos->simplePaginate( $request->per_page, ['*'], 'page', $request->page )->items()); } /** * Return a specific xmlInco. * * @param XmlInco $xmlInco * @return JsonResource */ public function show(XmlInco $xmlInco): JsonResource { // * Make sure we are accessing a xmlInco that belongs to our service. $this->authorize('arcadiaBrandBelongsToService', $xmlInco->arcadiaBrand); return new XmlIncoResource($xmlInco); } }