本文整理匯總了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]);
}
}