Привет, я загружаю отношение на ресурс API в laravel 5.6:
public function show($id)
{
return new YardResource(Yard::find($id)->with('inspections')->paginate(1));
}
YardResource
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'maf_id' => $this->maf_id,
'street' => $this->street,
'suburb' => $this->suburb,
'city' => $this->city,
'country' => $this->country,
'lat' => $this->lat,
'long' => $this->long,
'landowner_name' => $this->landowner_name,
'landowner_phone' => $this->landowner_phone,
'landowner_phone2' => $this->landowner_phone2,
'landowner_mobile' => $this->landowner_mobile,
'landowner_mobile2' => $this->landowner_mobile2,
'landowner_email' => $this->landowner_email,
'landowner_street' => $this->landowner_street,
'landowner_suburb' => $this->landowner_suburb,
'landowner_city' => $this->landowner_city,
'landowner_country' => $this->landowner_country,
'landowner_postcode' => $this->landowner_postcode,
'acquired_at' => $this->acquired_at,
'quarantined' => $this->quarantined,
'archived' => $this->archived,
'latest_inspection' => new Inspection($this->latestInspection),
'inspections' => InspectionResource::collection($this->whenLoaded('inspections')),
'tasks' => TaskResource::collection($this->tasks->where('completed', false)), // Get active tasks
'feedings' => FeedResource::collection($this->feeds),
'diseases' => DiseaseResource::collection($this->diseases),
'treatments' => TreatmentResource::collection($this->activeTreatments), // between dates
'yard_events' => YardEventResource::collection($this->yardEvents),
];
}
Я хочу разбить на страницы отношение проверок, но у меня нетудачи.
Есть эта ошибка:
Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id
Любая помощь будет отличной!