本文整理汇总了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'));
}
}
示例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);
}
示例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]);
}
}