本文整理汇总了PHP中app\models\Person::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::create方法的具体用法?PHP Person::create怎么用?PHP Person::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Person
的用法示例。
在下文中一共展示了Person::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: savePeople
/**
* Used to save people to the db.
* @param array $arrayOfPeople
* @return Array of ids
*/
public static function savePeople(array $arrayOfPeople)
{
$arrayOfPeopleIds = [];
foreach ($arrayOfPeople as $people) {
$person = Person::create($people);
array_push($arrayOfPeopleIds, $person->id);
}
return $arrayOfPeopleIds;
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$validator = Validator::make(Request::all(), ['name' => 'required', 'document' => 'required', 'email' => 'required|email|max:255|unique:persons', 'phone' => 'required', 'version_id' => 'required']);
if ($validator->fails()) {
return redirect()->back()->withErrors($validator->errors());
} else {
if (!$this->valDocument(Input::get('document'))) {
return redirect()->back()->withErrors(['The document field is invalid.']);
}
$person = Request::all();
Person::create($person);
return redirect('persons');
}
}
示例3: run
public function run()
{
Person::create(['first_name' => 'James', 'last_name' => 'Sample']);
}
示例4: make
protected function make() : Person
{
return Person::create();
}