• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Plan类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Plan的典型用法代码示例。如果您正苦于以下问题:PHP Plan类的具体用法?PHP Plan怎么用?PHP Plan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Plan类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: actionAdmin

 public function actionAdmin()
 {
     $model = new Plan('search');
     $model->unsetAttributes();
     if (isset($_GET['Plan'])) {
         $model->setAttributes($_GET['Plan']);
     }
     $this->render('admin', array('model' => $model));
 }
开发者ID:rapbore,项目名称:comar,代码行数:9,代码来源:PlanController.php


示例2: getShortestPath

 public function getShortestPath(Plan $plan)
 {
     $mutation = $this->selection->getMutations();
     $places = $plan->getPlaces();
     $from = array_shift($places);
     $roadmap = new Roadmap($places);
     $roadmap->addPlace($from);
     $roadmaps = $this->sortRoadmaps($this->explodeRoadmaps([$roadmap]));
     return $roadmaps[0];
 }
开发者ID:wdalmut,项目名称:tsp-genetic-algorithm,代码行数:10,代码来源:Life.php


示例3: testPayload

 public function testPayload()
 {
     $price = new Price();
     $plan = new Plan();
     foreach ($this->payload as $testCase) {
         echo "Testing case: " . json_encode($testCase) . "\n";
         $price->setPricePerMinute($testCase["price"]["ppm"]);
         $plan->setMinutes($testCase["plan"]["min"]);
         $plan->setFareAdditionalMin($testCase["plan"]["fare"]);
         $this->assertEquals($plan->calculateCallCost($price, $testCase["duration"]), $testCase["result"]);
     }
 }
开发者ID:luizcapu,项目名称:scuptel,代码行数:12,代码来源:PlanTest.php


示例4: actionIndex

 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $model = new PurchasedPlan();
     $form = new PurchasePlanForm();
     if (isset($_POST['PurchasedPlan'])) {
         $form->attributes = $_POST['PurchasedPlan'];
         if ($form->validate()) {
             if ($_POST['PurchasedPlan']['realPayment'] == 0) {
                 //$form->purchasePlan($this->getPlanType());
                 $this->redirect(array('index'));
             } else {
                 $wl = WhiteLabel::model()->findByPk(Yii::app()->user->getWhiteLabelId());
                 if ($wl == null) {
                     throw new Exception("Account doesn't exist");
                 }
                 $plan = Plan::model()->findByAttributes(array('plan_id' => $form->plan_id, 'wlabel_id' => Yii::app()->user->getWhiteLabelId(), 'type' => $this->getPlanType()));
                 if ($plan == null) {
                     throw new Exception("Plan doesn't exist");
                 }
                 if ($wl->payment_type == PaymentType::TYPE_PAYPAL) {
                     $this->processPayPalPayment($wl, $plan);
                 } else {
                     if ($wl->payment_type == PaymentType::TYPE_AUTHORIZENET) {
                         $this->processAuthnetPayment($wl, $plan);
                     }
                 }
                 exit;
             }
         }
     }
     if (isset($_GET['PurchasedPlan'])) {
         $model->attributes = $_GET['PurchasedPlan'];
     }
     $this->render('index', array('model' => $model, 'planType' => $this->getPlanType()));
 }
开发者ID:yasirgit,项目名称:hotmall,代码行数:38,代码来源:MyplansController.php


示例5: getDataProvider

 /**
  *
  * 改进:使用延迟绑定,将这个函数写在父类里面
  *返回某个用户所发布的所有计划列表
  * @return CActiveDataProvider $dataProvider  返回CActiveDataProvider对象
  * 使用attach的好处是随时绑定,不一定在初始化的时候绑定
  */
 public function getDataProvider(CFormModel &$condition)
 {
     $this->attachBehaviors(array('NearScopeBehavior' => array('class' => 'ext.behavior.NearScopeBehavior', 'latitude' => $condition->latitude, 'longitude' => $condition->longitude)));
     $dataProvider = new CActiveDataProvider(Plan::model()->unexpired()->near()->with('user'), array('pagination' => array('pageSize' => 20)));
     $dataProvider->setCriteria($this->addCondition($condition));
     return $dataProvider;
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:14,代码来源:Plan.php


示例6: ProrataDiscount

 public static function ProrataDiscount($account_id, $month_sub, $plan_data, $new_plan_cost, $rem_day, $num_of_days, $prorata_bal)
 {
     $plan_det = Plan::where('account_id', '=', $account_id)->get()->first();
     $old_plan_code = $plan_det->plan_code;
     $old_plan_amount = PlanCostDetail::where('plan_code', '=', $old_plan_code)->get()->first()->plan_cost;
     $old_plan_cost = round($old_plan_amount + $old_plan_amount * 0.14);
     $prorata_dis = $old_plan_cost - $prorata_bal;
     if ($month_sub == 'Monthly') {
         if ($plan_data != 0) {
             $prorata_cost = $new_plan_cost;
             $prorata_dis = $prorata_dis;
             $plan_amount = $new_plan_cost - $prorata_dis;
             return array("plan_amount" => $plan_amount, "prorata_dis" => $prorata_dis, "prorata_cost" => $prorata_cost);
         } else {
             $plan_amount = round($rem_day * ($new_plan_cost / $num_of_days)) - $prorata_dis;
             //var_dump($plan_cost_tax); die;
             $prorata_cost = $plan_amount;
             $prorata_dis = $new_plan_cost - $prorata_cost;
             return array("plan_amount" => $plan_amount, "prorata_dis" => $prorata_dis, "prorata_cost" => $prorata_cost);
         }
     } else {
         $plan_amount = $new_plan_cost;
         $prorata_cost = $new_plan_cost;
         $prorata_dis = 0;
         return array("plan_amount" => $plan_amount, "prorata_dis" => $prorata_dis, "prorata_cost" => $prorata_cost);
     }
 }
开发者ID:testoodoo,项目名称:OoodooSiteUp,代码行数:27,代码来源:PlanChangeDet.php


示例7: search

 /**
  * Search Licenses
  */
 static function search($q = NULL, $param = NULL, $product_code = NULL)
 {
     $_tbl_licenses = License::getTableName();
     $_tbl_licensesUses = LicensesUses::getTableName();
     $_tbl_transactions = Transaction::getTableName();
     $_tbl_purchases = Purchase::getTableName();
     $_tbl_products = Product::getTableName();
     $_tbl_plans = Plan::getTableName();
     $_tbl_buyers = Buyer::getTableName();
     $fields = array("{$_tbl_licenses}.*", DB::raw("COUNT({$_tbl_licensesUses}.id) AS totalUsed"), "{$_tbl_buyers}.first_name", "{$_tbl_buyers}.last_name", "{$_tbl_buyers}.email", "{$_tbl_products}.code", "{$_tbl_plans}.code AS plan_code", "{$_tbl_products}.api_key");
     $licenses = DB::table($_tbl_licenses)->leftJoin($_tbl_licensesUses, "{$_tbl_licensesUses}.license_id", '=', "{$_tbl_licenses}.id")->join($_tbl_transactions, "{$_tbl_transactions}.id", '=', "{$_tbl_licenses}.transaction_id")->join($_tbl_plans, "{$_tbl_transactions}.plan_id", '=', "{$_tbl_plans}.id")->join($_tbl_purchases, "{$_tbl_purchases}.id", '=', "{$_tbl_transactions}.purchase_id")->join($_tbl_products, "{$_tbl_products}.id", '=', "{$_tbl_purchases}.product_id")->join($_tbl_buyers, "{$_tbl_buyers}.id", '=', "{$_tbl_purchases}.buyer_id")->select($fields)->groupBy("{$_tbl_licenses}.id");
     $q = $q ? $q : Input::get('q');
     $param = $param ? $param : Input::get('param');
     if ($q) {
         if ($param == "key") {
             $licenses = $licenses->where("license_key", '=', $q);
         }
         if ($param == "email") {
             $licenses = $licenses->where("email", '=', $q);
         }
         if ($product_code) {
             $licenses = $licenses->where($_tbl_licenses . ".license_key", 'LIKE', strtoupper($product_code) . '-%');
         }
     }
     return $licenses->orderBy($_tbl_licenses . '.created_at', 'DESC')->paginate(25);
 }
开发者ID:michaelotto126,项目名称:dksolution,代码行数:29,代码来源:License.php


示例8: postGenerateLicense

 /**
  * Generate license
  */
 public function postGenerateLicense()
 {
     $rules = array('transaction_id' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('admin/utilities/generate-license')->withErrors($validator)->withInput();
     } else {
         $transaction_id = Input::get('transaction_id');
         if ($transaction = Transaction::where('id', '=', $transaction_id)->first()) {
             if ($license = License::where('transaction_id', '=', $transaction_id)->first()) {
                 Session::flash('alert_error', '<strong>Ooops!</strong> License for given transaction already exists.');
                 return Redirect::to('admin/licenses?q=' . $license->license_key . '&param=key');
             }
             $plan = Plan::where('id', '=', $transaction->plan_id)->first();
             if ($plan->has_license) {
                 $product = Product::where('id', '=', $plan->product_id)->first();
                 $license_key = License::generate($product->code);
                 // Save license
                 $license = new License();
                 $license->license_key = $license_key;
                 $license->transaction_id = $transaction_id;
                 $license->allowed_usage = $plan->license_allowed_usage;
                 $license->save();
                 Session::flash('alert_message', '<strong>Well done!</strong> You successfully have generated license key.');
                 return Redirect::to('admin/licenses?q=' . $license_key . '&param=key');
             } else {
                 Session::flash('alert_error', '<strong>Ooops!</strong> This plan does not allow to generate a license key.');
                 return Redirect::to('admin/utilities/generate-license');
             }
         } else {
             Session::flash('alert_error', '<strong>Ooops!</strong> Transaction was not found.');
             return Redirect::to('admin/utilities/generate-license');
         }
     }
 }
开发者ID:michaelotto126,项目名称:dksolution,代码行数:38,代码来源:UtilitiesController.php


示例9: actionDetail

 /**
  * 
  * 查看plan的详细。在里面就包括了评论等具体的内容,注意,评论则需要分页。
  * 因为plan本身已经返回,所以只返回评论的内容。
  */
 public function actionDetail($planId)
 {
     $plan = Plan::model()->findByPk('planId', 'planId=:planId', array(':planId' => $planId));
     $dataProvider = $plan->getComments();
     $this->page($dataProvider);
     $data = array('data' => $dataProvider);
     $this->render('detail', $data);
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:13,代码来源:PlanController.php


示例10: plan

 public function plan()
 {
     $plans = Plan::where('account_id', '=', $this->account_id)->get();
     if (count($plans) != 0) {
         return $plans->first();
     }
     return null;
 }
开发者ID:testoodoo,项目名称:OoodooSiteUp,代码行数:8,代码来源:CusDet.php


示例11: testTraerPlanesCompletosSinAnios

 function testTraerPlanesCompletosSinAnios()
 {
     $planIdSinAnios = 5;
     $params = array('recursive' => 3, 'conditions' => array('Plan.id' => $planIdSinAnios));
     $ps = $this->Plan->__findCompleto($buscaroSoloContar = 'buscar', $params);
     $this->assertEqual(count($ps), 1);
     $this->assertTrue(empty($ps[0]['Anio']));
 }
开发者ID:Navdeep736,项目名称:regetp01,代码行数:8,代码来源:plan.test.php


示例12: purchasePlan

 public function purchasePlan($planType, $advertiserId = '')
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         // load plan and its plan limits
         if ($planType == PlanType::ADVERTISER_PLAN) {
             $plan = Plan::model()->findByAttributes(array('plan_id' => $this->plan_id, 'wlabel_id' => Yii::app()->user->getWhiteLabelId(), 'type' => $planType));
         } else {
             $plan = Plan::model()->findByAttributes(array('plan_id' => $this->plan_id, 'type' => $planType));
         }
         if ($plan == null) {
             throw new Exception("Plan doesn't exist");
         }
         $planLimits = PlanLimit::model()->findAllByAttributes(array('plan_id' => $plan->plan_id));
         if ($planLimits == null) {
             //				 throw new Exception("Plan Limits don't exist");
         }
         // create new purchased_plans record
         $purchasedPlan = new PurchasedPlan();
         $purchasedPlan->plan_id = $plan->plan_id;
         if ($planType == PlanType::ADVERTISER_PLAN) {
             $purchasedPlan->wlabel_id = $plan->wlabel_id;
         } else {
             $purchasedPlan->wlabel_id = $this->wlabel_id;
         }
         $purchasedPlan->type = $plan->type;
         if ($planType == PlanType::ADVERTISER_PLAN) {
             if (Yii::app()->user->isAdvertiser()) {
                 $purchasedPlan->advertiser_id = Yii::app()->user->getAdvertiserId();
             } else {
                 $purchasedPlan->advertiser_id = $advertiserId;
             }
         } else {
         }
         $purchasedPlan->method = 0;
         $purchasedPlan->price = $plan->price;
         $purchasedPlan->date_created = date("Y-m-d h:i:s");
         if (!$purchasedPlan->validate()) {
             throw new Exception("Plan purchase cannot be saved: " . $this->putErrorsToString($purchasedPlan->getErrors()));
         }
         $purchasedPlan->save();
         // create new purchased_plans payments record
         $purchasedPlanPayment = new PurchasedPlanPayment();
         $purchasedPlanPayment->pplan_id = $purchasedPlan->pplan_id;
         $purchasedPlanPayment->date_paid = $purchasedPlan->date_created;
         $purchasedPlanPayment->date_expire = Date('y-m-d', strtotime("+{$plan->duration} day"));
         $purchasedPlanPayment->transaction_id = 'TEST_PAYMENT';
         if (!$purchasedPlanPayment->validate()) {
             throw new Exception("Plan payment cannot be saved: " . $this->putErrorsToString($purchasedPlanPayment->getErrors()));
         }
         $purchasedPlanPayment->save();
     } catch (Exception $e) {
         $transaction->rollBack();
         throw new CHttpException(400, 'DB Exception: ' . $e->getMessage());
     }
     $transaction->commit();
     return false;
 }
开发者ID:yasirgit,项目名称:hotmall,代码行数:58,代码来源:PurchasePlanForm.php


示例13: actionIndex

 public function actionIndex()
 {
     $this->layout = 'login';
     $wlabelId = isset($_REQUEST['wid']) ? $_REQUEST['wid'] : '';
     if ($wlabelId == '') {
         throw new CHttpException(404, 'Bad parameter wid');
     }
     $planId = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : '';
     if ($planId == '') {
         throw new CHttpException(404, 'Bad parameter pid');
     }
     $advertiserId = isset($_REQUEST['aid']) ? $_REQUEST['aid'] : '';
     if ($advertiserId == '') {
         throw new CHttpException(404, 'Bad parameter aid');
     }
     $returnUrl = isset($_REQUEST['return']) ? $_REQUEST['return'] : '';
     if ($returnUrl == '') {
         throw new CHttpException(404, 'Bad parameter return');
     }
     $wl = WhiteLabel::model()->findByPk(Yii::app()->user->getWhiteLabelId());
     if ($wl == null) {
         throw new Exception("Account doesn't exist");
     }
     $plan = Plan::model()->findByAttributes(array('plan_id' => $planId, 'wlabel_id' => $wlabelId));
     if ($plan == null) {
         throw new CHttpException(404, 'Cannot find plan!');
     }
     $advertiser = Advertiser::model()->findByAttributes(array('advertiser_id' => $planId, 'wlabel_id' => $advertiserId));
     if ($plan == null) {
         throw new CHttpException(404, 'Cannot find advertiser!');
     }
     $form = new AuthorizenetPaymentForm();
     if (isset($_POST['AuthorizenetPaymentForm'])) {
         $form->attributes = $_POST['AuthorizenetPaymentForm'];
         $form->advertiser_id = $advertiserId;
         $form->wlabel_id = $wlabelId;
         $form->plan_id = $plan->plan_id;
         $form->refId = $plan->plan_id;
         $form->name = "Plan Subscription";
         $form->unit = "days";
         $form->totalOccurrences = 999;
         $form->trialOccurrences = 0;
         $form->trialAmount = 0;
         $form->startDate = date('Y-m-d');
         $form->length = $plan->duration;
         $form->amount = $plan->price;
         if ($form->validate()) {
             if ($form->sendCreateSubscription($wl, $plan)) {
                 $this->redirect($returnUrl);
             }
         }
     }
     if (isset($_GET['AuthorizenetPaymentForm'])) {
         $form->attributes = $_GET['AuthorizenetPaymentForm'];
     }
     $this->render('form_authnet_payment', array('model' => $form));
 }
开发者ID:yasirgit,项目名称:hotmall,代码行数:57,代码来源:PayformController.php


示例14: retrieveOrCreatePlan

 /**
  * Verify that a plan with a given ID exists, or create a new one if it does
  * not.
  */
 protected static function retrieveOrCreatePlan($id)
 {
     self::authorizeFromEnv();
     try {
         $plan = Plan::retrieve($id);
     } catch (Error\InvalidRequest $exception) {
         $plan = Plan::create(array('id' => $id, 'amount' => 0, 'currency' => 'usd', 'interval' => 'month', 'name' => 'Gold Test Plan'));
     }
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:13,代码来源:TestCase.php


示例15: get_delete

 public function get_delete($id = NULL)
 {
     $plan = Plan::find($id);
     if (empty($plan)) {
         return View::make('msg.error')->with('error', 'Plan doesn\'t exist.');
     }
     $plan->delete();
     return Redirect::to('/admin/plan/overview');
 }
开发者ID:albertpaulp,项目名称:PrettyBoot,代码行数:9,代码来源:plan.php


示例16: actionIndex

 public function actionIndex()
 {
     $plan = Plan::model();
     $searchForm = $this->initParams('SearchForm', 'new');
     $dataProvider = $plan->getDataProvider($searchForm);
     $this->page($dataProvider, true);
     $data = array('search' => $searchForm, 'dataProvider' => $dataProvider);
     $this->render('index', $data);
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:9,代码来源:DefaultController.php


示例17: generate

 public static function generate($input)
 {
     $res = [];
     $plan = Plan::findOrFail($input['plan_id']);
     $voucher['expires_on'] = self::_makeExpiry($input['validity'], $input['validity_unit']);
     $voucher['created_at'] = time();
     $voucher['plan_name'] = $plan->name;
     $voucher['plan_type'] = $plan->plan_type;
     $voucher['sim_sessions'] = $plan->sim_sessions;
     $voucher['interim_updates'] = $plan->interim_updates;
     $voucher['price'] = $plan->price;
     $voucher['validity'] = $plan->validity;
     $voucher['validity_unit'] = $plan->validity_unit;
     $voucher['policy_type'] = $plan->policy_type;
     if ($plan->plan_type == 1) {
         //if limited
         $limit = $plan->limit->toArray();
         if ($plan->limit->aq_access == 1) {
             // $limit['aq_access'] = 1;
             $aq_policy = Policy::findOrFail($plan->limit->aq_policy);
             $limit['aq_policy'] = mikrotikRateLimit($aq_policy->toArray());
         }
         $voucher_limit = VoucherLimit::create($limit);
         $voucher['limit_id'] = $voucher_limit->id;
     }
     if ($plan->policy_type == 'Policy') {
         $policy = new VoucherPolicy(['bw_policy' => mikrotikRateLimit($plan->policy->toArray())]);
         $policy->save();
     } elseif ($plan->policy_type == 'PolicySchema') {
         $days = ['mo' => 'monday', 'tu' => 'tuesday', 'we' => 'wednesday', 'th' => 'thursday', 'fr' => 'friday', 'sa' => 'saturday', 'su' => 'sunday'];
         foreach ($days as $d => $day) {
             $tpl = $plan->policy->{$day}->toArray();
             $type = ['bw_policy', 'pr_policy', 'sec_policy'];
             foreach ($type as $t) {
                 if (!is_null($tpl[$t])) {
                     $policy = Policy::find($tpl[$t])->toArray();
                     $tpl[$t] = mikrotikRateLimit($policy);
                 }
             }
             $template = VoucherPolicySchemaTemplate::create($tpl);
             $schema[$d] = $template->id;
         }
         $policy = VoucherPolicySchema::create($schema);
     }
     $voucher['policy_id'] = $policy->id;
     for ($i = 0; $i < $input['count']; $i++) {
         $voucher['pin'] = self::generatePin();
         $voucher['expires_on'] = self::_makeExpiry($input['validity'], $input['validity_unit']);
         $v = new Voucher($voucher);
         if (!$v->save()) {
             return FALSE;
         }
         $res[] = $v->pin;
     }
     return $res;
 }
开发者ID:guilhermefilippo,项目名称:access-manager,代码行数:56,代码来源:Voucher.php


示例18: billUpdate

 public static function billUpdate($id, $account_id, $for_month, $other_charges_new, $plan_code, $plan_start_date)
 {
     $bill = Bill::where('account_id', '=', $account_id)->where('for_month', $for_month)->get()->first();
     // var_dump($bill,$for_month,$account_id);die;
     if (count($bill) != 0) {
         $plan = Plan::where('account_id', '=', $account_id)->get()->first();
         $plan_cost_det = PlanCostDetail::where('plan_code', '=', $plan_code)->get()->first();
         $planChange = PlanChangeDet::where('account_id', $account_id)->where('status', 'payment pending')->first();
         if (count($planChange) != 0) {
             $planChange->plan_code = $plan_code;
             $planChange->plan_name = $plan_cost_det->plan_desc;
             $planChange->plan_change_date = $plan_start_date;
             $planChange->request_id = "44444";
             $planChange->save();
         } else {
             $planchange = new PlanChangeDet();
             $planchange->account_id = $account_id;
             $planchange->plan_code = $plan_code;
             $planchange->plan_name = $plan_cost_det->plan_desc;
             $planchange->plan_change_date = $plan_start_date;
             $planchange->request_id = "44444";
             $planchange->remarks = $bill->bill_no;
             $planchange->status = "payment pending";
             $planchange->save();
         }
         $account_id = $account_id;
         $for_month = $for_month;
         $other_charges_exit = OtherCharges::where('account_id', '=', $account_id)->where('for_month', $for_month)->where('id', '!=', $id)->sum('amount');
         $other_charges_update = OtherCharges::where('id', $id)->first();
         if (count($other_charges_update) != 0) {
             $sub_total = $bill->sub_total;
             $service_tax = $bill->service_tax;
             $total_charges = $sub_total + $service_tax;
             $amount_before_due_date = intval($bill->amount_before_due_date + $other_charges_update->amount);
             $amount_after_due_date = intval($bill->amount_before_due_date + $other_charges_update->amount);
             $other_charges_update->is_considered = 1;
             $other_charges_update->remarks = "planchange bill no " . $bill->bill_no;
             $other_charges_update->save();
             $other_charges = $other_charges_update->amount;
             $amount_paid = $bill->amount_paid;
         }
         if ($amount_paid == 0) {
             $status = "not_paid";
         } else {
             if ($amount_before_due_date > $amount_paid) {
                 $status = "partially_paid";
             } else {
                 if ($amount_before_due_date <= $amount_paid) {
                     $status = "paid";
                 }
             }
         }
         DB::table('bill_det')->where('bill_no', '=', $bill->bill_no)->update(array('other_charges' => $other_charges + $other_charges_exit, 'amount_before_due_date' => $amount_before_due_date, 'amount_after_due_date' => $amount_after_due_date, 'amount_paid' => $amount_paid, 'status' => $status));
         return DB::table('bill_det')->where('bill_no', '=', $bill->bill_no)->first();
     }
 }
开发者ID:testoodoo,项目名称:OoodooSiteUp,代码行数:56,代码来源:PlanChangeDetail.php


示例19: testSave

 public function testSave()
 {
     self::authorizeFromEnv();
     $planID = 'gold-' . self::generateRandomString(20);
     $p = Plan::create(array('amount' => 2000, 'interval' => 'month', 'currency' => 'usd', 'name' => 'Plan', 'id' => $planID));
     $p->name = 'A new plan name';
     $p->save();
     $this->assertSame($p->name, 'A new plan name');
     $stripePlan = Plan::retrieve($planID);
     $this->assertSame($p->name, $stripePlan->name);
 }
开发者ID:Enflick,项目名称:stripe-php,代码行数:11,代码来源:PlanTest.php


示例20: AssignPlan

 public static function AssignPlan($user_id, $plan_id, $price = NULL)
 {
     DB::transaction(function () use($user_id, $plan_id, $price) {
         $oldPlan = APActivePlan::where('user_id', $user_id)->first();
         if (!is_null($oldPlan)) {
             self::updatePlanHistory($oldPlan);
         } else {
             $oldPlan = new ApActivePlan();
         }
         $plan = Plan::findOrFail($plan_id);
         $newPlan = ['user_id' => $user_id, 'plan_name' => $plan->name, 'plan_type' => $plan->plan_type, 'policy_type' => $plan->policy_type, 'sim_sessions' => $plan->sim_sessions, 'interim_updates' => $plan->interim_updates, 'aq_invocked' => 0, 'price' => $plan->price, 'time_balance' => NULL, 'data_balance' => NULL, 'assigned_on' => date("Y-m-d H:i:s"), 'validity' => $plan->validity, 'validity_unit' => $plan->validity_unit];
         if ($price != NULL) {
             $newPlan['price'] = $price;
         }
         if ($plan->plan_type == LIMITED) {
             $limit = $plan->limit;
             if ($limit->limit_type == TIME_LIMIT || $limit->limit_type == BOTH_LIMITS) {
                 $newPlan['time_balance'] = $limit->time_limit * constant($limit->time_unit);
             }
             if ($limit->limit_type == DATA_LIMIT || $limit->limit_type == BOTH_LIMITS) {
                 $newPlan['data_balance'] = $limit->data_limit * constant($limit->data_unit);
             }
             if ($limit->aq_access == ALLOWED) {
                 $aq_policy = Policy::findOrFail($limit->aq_policy);
                 $limit->aq_policy = mikrotikRateLimit($aq_policy->toArray());
             }
             $planLimit = APLimit::create($limit->toArray());
             $newPlan['limit_id'] = $planLimit->id;
         }
         if ($plan->policy_type == 'Policy') {
             $policy = APPolicy::create(['bw_policy' => mikrotikRateLimit($plan->policy->toArray())]);
         } elseif ($plan->policy_type == 'PolicySchema') {
             $days = ['mo' => 'monday', 'tu' => 'tuesday', 'we' => 'wednesday', 'th' => 'thursday', 'fr' => 'friday', 'sa' => 'saturday', 'su' => 'sunday'];
             foreach ($days as $d) {
                 $tpl = $plan->policy->{$day}->toArray();
                 $types = ['bw_policy', 'pr_policy', 'sec_policy'];
                 foreach ($types as $t) {
                     if (!is_null($tpl[$t])) {
                         $policy = Policy::find($tpl[$t])->toArray();
                         $tpl[$t] = mikrotikRateLimit($policy);
                     }
                 }
                 $template = APPolicySchemaTemplate::create($tpl);
                 $schema[$d] = $template->id;
             }
             $policy = APPolicySchema::create($schema);
         }
         $newPlan['policy_id'] = $policy->id;
         $oldPlan->fill($newPlan);
         $oldPlan->save();
         return TRUE;
     });
 }
开发者ID:guilhermefilippo,项目名称:access-manager,代码行数:53,代码来源:APActivePlan.php



注:本文中的Plan类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Planning类代码示例发布时间:2022-05-23
下一篇:
PHP Place类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap