public function get(RESTRequest $request) { $identifiers = $request->getIdentifiers(); if (!empty($identifiers[0])) { $plan_id = (int) $identifiers[0]; } else { $plan_id = null; } $result = Tariff::getDetailedPlanInfo($plan_id); return $result; }
public static function getDetailedPackageInfo($package_id = null) { if (!empty($package_id)) { $info = self::getPackageById($package_id); if (!empty($info)) { $info['services'] = Tariff::getServicesForPackage($info['id']); } } else { $info = self::getAllPackages(); $info = array_map(function ($package) { $package['services'] = Tariff::getServicesForPackage($package['id']); return $package; }, $info); } return $info; }