middleware('auth'); } public function index(Request $request) { list($permittingOwnerIds, $date, $owner_id) = $this->getRequestParams($request); $owners = \App\Owner::query()->find($permittingOwnerIds); $owner = \App\Owner::query()->find($owner_id); $ownerAreas = OwnerAreaReport::query() ->with('ownerStoragePriceModel:id,using_type') ->where('owner_id', $owner_id) ->where('counting_month', $date) ->get(); $ownerBillReport = \App\OwnerBillReport::query() ->selectRaw('storage_fee') ->where('owner_id', $owner_id) ->where('counting_month', $date) ->first(); } /** * @param Request $request * @return array */ private function getRequestParams(Request $request): array { $this->service = app('OwnerLogisticFeeReportService'); $this->userService = app('UserService'); $permittingOwnerIds = $this->userService->getPermittingOwnerIds(auth()->user()); if (is_null($request->year) || is_null($request->month)) { $date = now()->subMonth()->startOfMonth()->toDateString(); } else { $date = $request->year . '-' . $request->month . '-' . '01'; } if (is_null($request->owner_id)) { $owner_id = $permittingOwnerIds[0]; } else { $owner_id = $request->owner_id; } return array($permittingOwnerIds, $date, $owner_id); } }