authorize('view', $customer); $this->authorize('view report', $customer->company); $type = $request->validated('type'); $statement = $this->customerStatementQuery->statement( $customer, $type, Carbon::createFromFormat('Y-m-d', $request->validated('from_date')), Carbon::createFromFormat('Y-m-d', $request->validated($type === CustomerStatementQuery::TYPE_OUTSTANDING ? 'as_of' : 'to_date')), (int) $request->validated('per_page', 50), (int) $request->validated('page', 1), ); return new CustomerStatementResource($statement); } }