all()); $totalNum = $query->sum('yield'); //总产量 $list = $query->simplePaginate(Paginator::resolvePerPage('per_page', 20, 50)); $list->load(['base', 'createdBy']); return $this->json([ 'total' => $totalNum, 'list' => CropYieldResource::collection($list), ]); } public function store(CropYieldRequest $request) { //-todo return $this->success('添加成功'); } public function show(CropYield $cropYield) { $cropYield->load(['base', 'crop', 'createdBy']); return $this->json(CropYieldResource::make($cropYield)); } public function update(CropYield $cropYield, CropYieldUpdateRequest $request) { //-todo return $this->success('修改成功'); } public function destroy(CropYield $cropYield) { $cropYield->delete(); return $this->success('删除成功'); } }