当前位置: 首页>>代码示例>>PHP>>正文


PHP Plan::create方法代码示例

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


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

示例1: 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

示例2: 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

示例3: run

 public function run()
 {
     // Create a new instance of Faker
     $faker = Faker\Factory::create();
     // Create a plan
     $plan = Plan::create(['user_id' => 2]);
     // Attach an instructor
     //$plan->instructors()->attach(1);
     // Create some goals
     $goals = [new Goal(['plan_id' => 1, 'title' => ucwords(implode(' ', $faker->words(mt_rand(4, 10)))), 'summary' => $faker->text(mt_rand(25, 200)), 'created_at' => $faker->dateTimeBetween('-1 years'), 'updated_at' => $faker->dateTimeBetween('-1 years')]), new Goal(['plan_id' => 1, 'title' => ucwords(implode(' ', $faker->words(mt_rand(4, 10)))), 'summary' => $faker->text(mt_rand(25, 200)), 'created_at' => $faker->dateTimeBetween('-1 years'), 'updated_at' => $faker->dateTimeBetween('-1 years')]), new Goal(['plan_id' => 1, 'title' => ucwords(implode(' ', $faker->words(mt_rand(4, 10)))), 'summary' => $faker->text(mt_rand(25, 200)), 'created_at' => $faker->dateTimeBetween('-1 years'), 'updated_at' => $faker->dateTimeBetween('-1 years')]), new Goal(['plan_id' => 1, 'title' => ucwords(implode(' ', $faker->words(mt_rand(4, 10)))), 'summary' => $faker->text(mt_rand(25, 200)), 'created_at' => $faker->dateTimeBetween('-1 years'), 'updated_at' => $faker->dateTimeBetween('-1 years')])];
     // Attach the goals to the plan
     $plan->goals()->saveMany($goals);
     // Create some comments
     for ($i = 0; $i < 15; $i++) {
         $date = $faker->dateTimeBetween('-1 years');
         Comment::create(['goal_id' => mt_rand(1, 4), 'user_id' => mt_rand(1, 2), 'content' => $faker->text(mt_rand(10, 300)), 'created_at' => $date, 'updated_at' => $date]);
     }
 }
开发者ID:kleitz,项目名称:bjga-scheduler,代码行数:18,代码来源:PlanSeeder.php


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