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