本文整理汇总了PHP中Plan::getActualPlans方法的典型用法代码示例。如果您正苦于以下问题:PHP Plan::getActualPlans方法的具体用法?PHP Plan::getActualPlans怎么用?PHP Plan::getActualPlans使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plan
的用法示例。
在下文中一共展示了Plan::getActualPlans方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: plans
public function plans()
{
$post = $this->input->post();
if (!empty($post)) {
if (isset($post['planId'])) {
$selectedPlan = $post['planId'];
redirect('auth/register/' . $selectedPlan, 'refresh');
}
}
$feature = new Feature();
$plan = new Plan();
$this->template->set('features', $feature->get());
$withTrial = !$this->ion_auth->logged_in();
CssJs::getInst()->add_js('libs/eq-height.js');
$this->template->set('plans', $plan->getActualPlans($withTrial));
$this->template->set('options', $this->config->config['period_qualifier']);
$this->template->render();
}
示例2: edit
public function edit()
{
$options = $this->config->config['period_qualifier'];
$error = array();
$plan = new Plan();
$features = new Feature();
$request = $this->getRequest();
//check if data was sent
if ($this->isRequestMethod('POST')) {
$weight = $request->request->get('plan_weight', '') ?: (int) $plan->getActualPlans()->weight + 1;
$plan->clear();
$plan->get_by_id($request->request->get('id'));
$plan->weight = $weight;
$plan->name = $request->request->get('name');
$trial = $request->request->get('trial');
$plan->trial = !empty($trial);
$special = $request->request->get('special');
$plan->special = !empty($special);
$featuresIds = $request->request->get('feature');
$saveFeatures = array();
$saveFeaturesIds = array();
//check if features was selected
if (implode('', $featuresIds) == '') {
$error[] = lang('attached_features_count_error');
} else {
$weight = 1;
//save features of plan
foreach ($featuresIds as $id) {
if ($id) {
$plansFeature = new Plans_feature($request->request->get('feature_' . $id . '_plansfeatureid', ''));
$plansFeature->feature_id = $id;
if ($request->request->has('feature_' . $id . '_value')) {
$value = $request->request->get('feature_' . $id . '_value');
$featureValidator = new Feature($id);
if ($featureValidator->validValue($value)) {
$plansFeature->value = $value;
} else {
$error[] = lang('attached_features_type_error', [$featureValidator->name, $featureValidator->type]);
}
}
$plansFeature->weight = $weight;
if ($plansFeature->save()) {
$saveFeatures[] = $plansFeature;
$saveFeaturesIds[] = $plansFeature->id;
$weight++;
}
}
}
}
//save periods of plan
$savePeriods = array();
$savePeriodsIds = array();
if ($count = count($request->request->get('period_id'))) {
$periodId = $request->request->get('period_id');
$period = $request->request->get('period');
$qualifier = $request->request->get('qualifier');
$price = $request->request->get('price');
for ($i = 0; $i < $count; $i++) {
$planPeriod = new Plans_period($periodId[$i]);
$planPeriod->period = $period[$i];
$planPeriod->qualifier = $qualifier[$i];
$planPeriod->price = $price[$i];
if ($planPeriod->save()) {
$savePeriods[] = $planPeriod;
$savePeriodsIds[] = $planPeriod->id;
}
if ($planPeriod->error->string) {
$error[] = $planPeriod->error->string;
}
}
}
//save plan with related features and period
if (empty($error)) {
$plan->save(array($saveFeatures, $savePeriods));
$plan->createStripePlans();
}
if ($plan->errors->string) {
$error[] = $plan->errors->string;
}
if (!empty($error)) {
$this->addFlash(implode('', $error));
$this->session->set_flashdata('recent', $request->request->all());
$planParam = $plan->id ? '?plan=' . $plan->id : '';
redirect('/admin/manage_plans/edit' . $planParam);
} else {
$plan->deleteOldPlanPeriods($savePeriodsIds);
$plan->deleteOldPlanfeatures($saveFeaturesIds);
}
redirect('/admin/manage_plans/');
}
$planId = $request->query->get('plan', '');
$plan->get_by_id($planId);
$plansFeatures = $plan->getAttachedFeatures();
$plansPeriod = $plan->plans_period->get();
//fill data after bad validation
if ($recent = $this->session->flashdata('recent')) {
//recent selected features
foreach ($plansFeatures as $planFeature) {
$featureId = $planFeature->feature_id;
if (in_array($featureId, $recent['feature'])) {
//.........这里部分代码省略.........