本文整理汇总了PHP中Lesson::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Lesson::create方法的具体用法?PHP Lesson::create怎么用?PHP Lesson::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lesson
的用法示例。
在下文中一共展示了Lesson::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 30) as $index) {
Lesson::create(['title' => $faker->sentence(5), 'body' => $faker->paragraph(4), 'some_bool' => $faker->boolean()]);
}
}
示例2: makeLesson
/**
* @param array $lessonFields
*/
protected function makeLesson($lessonFields = [])
{
$lesson = array_merge(['title' => $this->fake->sentence, 'body' => $this->fake->paragraph, 'some_bool' => $this->fake->boolean], $lessonFields);
while ($this->times--) {
Lesson::create($lesson);
}
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
if (!Input::get('title') or !Input::get('body')) {
return $this->respondUnprocessableEntity('Parameters failed validation for a lesson.');
}
Lesson::create(Input::all());
return $this->respondCreated('Lesson successfully created.');
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
if (!Input::get('title') or !Input::get('body')) {
return $this->setStatusCode(422)->respondWithError('Failed input the lesson');
}
Lesson::create(Input::all());
return $this->respondCreated('Lesson Successfully created');
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$lesson = Lesson::create(Input::all());
// Alternatively, fire and listen for an event
// Then, call this from the listener.
Notify::lessonSubscribers($lesson);
return 'Success';
// or redirect or whatever
}