本文整理汇总了PHP中Person::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::create方法的具体用法?PHP Person::create怎么用?PHP Person::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created person in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Person::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
Person::create($data);
return Redirect::route('people.index');
}
示例2: run
public function run()
{
$faker = Faker\Factory::create();
Person::truncate();
// clear table
$person = Person::create(['slug' => 'lincoln', 'alias' => "The Abraham Lincoln", 'url_slug' => 'abraham-lincoln', 'first_name' => 'Abraham', 'last_name' => 'Lincoln', 'url_slug' => 'abraham-lincoln', 'favorite_color' => 'White', 'meta_title' => 'Abraham Lincoln, the Ultimate Abolitionist', 'meta_description' => 'You have no oath registered in Heaven to destroy the government,
while I shall have the most solemn one to preserve, protect and defend it.']);
foreach (range(1, 5) as $index) {
$alias = $faker->name;
$person = Person::create(['slug' => substr(preg_replace("/[^a-z0-9 ]/", '', strtolower($faker->userName)), 0, 16), 'alias' => $alias, 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'url_slug' => $faker->slug, 'favorite_color' => $faker->colorName, 'meta_title' => $alias . ' Details', 'meta_description' => $faker->paragraph]);
}
}
示例3: testSearch
/**
* @covers \Ixudra\Portfolio\Repositories\Eloquent\EloquentCompanyRepository::search()
*/
public function testSearch()
{
$company1 = Person::create(array('name' => 'Foo_first_name', 'email' => 'foz@bar.com', 'url' => 'http://bar.com'));
$company2 = Person::create(array('name' => 'Bar_first_name', 'email' => 'baz@bar.com', 'url' => 'http://foo.com'));
$company3 = Person::create(array('name' => 'Foz_first_name', 'email' => 'fow@bar.com', 'url' => 'http://baz.com'));
$company4 = Person::create(array('name' => 'Baz_first_name', 'email' => 'baw@bar.com', 'url' => 'http://fow.com'));
$company5 = Person::create(array('name' => 'Fow_first_name', 'email' => 'foz@foo.com', 'url' => 'http://fow.com'));
$filters = array('query' => 'Foo');
$paginator = $this->companyRepository->search($filters, 50, true);
$companies = $paginator->getCollection();
$this->assertCount(5, $companies);
$this->assertCollectionWithOnlyInstancesOf('\\Ixudra\\Portfolio\\Models\\Company', $companies);
$this->assertCollectionContains(array($company1, $company2, $company5), $companies);
}
示例4: testApiKeyErrorHandling
public function testApiKeyErrorHandling()
{
BlockScore::$apiKey = 'sk_test_11111111111111111111111111111111';
try {
Person::create(array('name_first' => 'Jane', 'name_last' => 'Doe', 'birth_day' => 1, 'birth_month' => 1, 'birth_year' => 1990, 'document_type' => 'ssn', 'document_value' => '0000', 'address_street1' => '123 Something Ave', 'address_city' => 'Newton Falls', 'address_subdivision' => 'OH', 'address_postal_code' => '44444', 'address_country_code' => 'US'));
// Always fail
$this->assertTrue(false);
} catch (Util\Exception $e) {
$expected = 'invalid_request_error';
$this->assertSame($expected, $e->type);
$this->assertTrue($e instanceof Util\Exception);
}
self::setTestApiKey();
}
示例5: run
public function run()
{
Eloquent::unguard();
/**
* Clearing table
*/
DB::table('persons')->delete();
/**
* Creating persons
*/
Person::create(array('prsn_name' => 'Max', 'prsn_ldap_id' => '1111', 'prsn_status' => 'kandidat', 'clb_id' => '1'));
Person::create(array('prsn_name' => 'Otto', 'prsn_ldap_id' => '1222', 'prsn_status' => 'aktiv', 'clb_id' => '1'));
Person::create(array('prsn_name' => 'Lena', 'prsn_ldap_id' => '1333', 'prsn_status' => 'veteran', 'clb_id' => '1'));
Person::create(array('prsn_name' => 'THOR'));
/**
* reporting result to console
*/
$this->command->info('Four example persons created - members Max, Otto, Lena and a guest THOR.');
}
示例6: Person
<?php
require_once __DIR__ . '/../../ActiveRecord.php';
// initialize ActiveRecord
ActiveRecord\Config::initialize(function ($cfg) {
$cfg->set_model_directory(__DIR__ . '/models');
$cfg->set_connections(array('development' => 'mysql://test:test@127.0.0.1/orders_test'));
// you can change the default connection with the below
//$cfg->set_default_connection('production');
});
// create some people
$jax = new Person(array('name' => 'Jax', 'state' => 'CA'));
$jax->save();
// compact way to create and save a model
$tito = Person::create(array('name' => 'Tito', 'state' => 'VA'));
// place orders. tax is automatically applied in a callback
// create_orders will automatically place the created model into $tito->orders
// even if it failed validation
$pokemon = $tito->create_orders(array('item_name' => 'Live Pokemon', 'price' => 6999.99));
$coal = $tito->create_orders(array('item_name' => 'Lump of Coal', 'price' => 100.0));
$freebie = $tito->create_orders(array('item_name' => 'Freebie', 'price' => -100.99));
if (count($freebie->errors) > 0) {
echo "[FAILED] saving order {$freebie->item_name}: " . join(', ', $freebie->errors->full_messages()) . "\n\n";
}
// payments
$pokemon->create_payments(array('amount' => 1.99, 'person_id' => $tito->id));
$pokemon->create_payments(array('amount' => 4999.5, 'person_id' => $tito->id));
$pokemon->create_payments(array('amount' => 2.5, 'person_id' => $jax->id));
// reload since we don't want the freebie to show up (because it failed validation)
$tito->reload();
echo "{$tito->name} has " . count($tito->orders) . " orders for: " . join(', ', ActiveRecord\collect($tito->orders, 'item_name')) . "\n\n";
示例7: test_collection_and_back_json
public function test_collection_and_back_json()
{
$person = new Person();
$p1 = $person->create(array('first_name' => 'Hansi', 'last_name' => 'Müller', 'email' => 'hans@mueller.com'));
$p1->account->create(array('username' => 'hansi', 'password' => 'wilma'));
$p2 = $person->create(array('first_name' => 'Friedrich', 'last_name' => 'Holz', 'email' => 'friedel@holz.de'));
$p2->account->create(array('username' => 'hansi', 'password' => 'wilma'));
$json = $person->toJson(array('collection' => array($p1, $p2), 'include' => 'account'));
$people_reloaded = $person->fromJson($json);
$this->assertEqual($p1->first_name, $people_reloaded[0]->first_name);
$this->assertEqual($p2->first_name, $people_reloaded[1]->first_name);
$this->assertEqual($p1->account->id, $people_reloaded[0]->account->id);
$this->assertEqual($p2->account->id, $people_reloaded[1]->account->id);
}
示例8: processView
function processView()
{
$GLOBALS['system']->includeDBClass('family');
$this->_family = new Family();
if (array_get($_REQUEST, 'new_family_submitted')) {
// some initial checks
$i = 0;
$found_member = FALSE;
while (isset($_POST['members_' . $i . '_first_name'])) {
if (!empty($_POST['members_' . $i . '_first_name'])) {
$found_member = TRUE;
}
$i++;
}
if (!$found_member) {
add_message('New family must have at least one member', 'failure');
return FALSE;
}
if ($GLOBALS['user_system']->havePerm(PERM_EDITNOTE)) {
if (REQUIRE_INITIAL_NOTE && empty($_POST['initial_note_subject'])) {
add_message("A subject must be supplied for the initial family note", 'failure');
return FALSE;
}
}
$GLOBALS['system']->doTransaction('begin');
// Create the family record itself
$this->_family->processForm();
$success = $this->_family->create();
if ($success) {
// Add members
$i = 0;
$members = array();
$GLOBALS['system']->includeDBClass('person');
while (isset($_POST['members_' . $i . '_first_name'])) {
if (!empty($_POST['members_' . $i . '_first_name'])) {
$member = new Person();
$member->setValue('familyid', $this->_family->id);
$member->processForm('members_' . $i . '_');
if (!$member->create()) {
$success = FALSE;
break;
}
$members[] =& $member;
}
$i++;
}
}
if ($success) {
if ($GLOBALS['user_system']->havePerm(PERM_EDITNOTE)) {
if (REQUIRE_INITIAL_NOTE || !empty($_POST['initial_note_subject'])) {
// Add note
if (count($members) > 1) {
$GLOBALS['system']->includeDBClass('family_note');
$note = new Family_Note();
$note->setValue('familyid', $this->_family->id);
} else {
$GLOBALS['system']->includeDBClass('person_note');
$note = new Person_Note();
$note->setValue('personid', $members[0]->id);
}
$note->processForm('initial_note_');
$success = $note->create();
}
}
if (!empty($_POST['execute_plan'])) {
foreach ($_POST['execute_plan'] as $planid) {
$plan = $GLOBALS['system']->getDBObject('action_plan', $planid);
$plan->execute('family', $this->_family->id, process_widget('plan_reference_date', array('type' => 'date')));
}
}
}
// Before committing, check for duplicates
if (empty($_REQUEST['override_dup_check'])) {
$this->_similar_families = $this->_family->findSimilarFamilies();
if (!empty($this->_similar_families)) {
$GLOBALS['system']->doTransaction('rollback');
return;
}
}
if ($success) {
$GLOBALS['system']->doTransaction('commit');
add_message('Family Created');
redirect('families', array('familyid' => $this->_family->id));
} else {
$GLOBALS['system']->doTransaction('rollback');
$this->_family->id = 0;
add_message('Error during family creation, family not created', 'failure');
}
}
}
示例9: onAdd
/**
* Adds new person to the schedule entry.
*
* @param $entry
* @return void
*/
private function onAdd($entry)
{
if (Input::get('ldapId' . $entry->id) == '') {
// If no LDAP id provided - create new GUEST person
$person = new Person();
// LDAP ID
$person->prsn_ldap_id = null;
// NAME
$person->prsn_name = Input::get('userName' . $entry->id);
// PERSON STATUS = empty for guests
} else {
// Find existing MEMBER person in DB
$person = Person::where('prsn_ldap_id', '=', Input::get('ldapId' . $entry->id))->first();
// If not found - create new person with data provided
if (is_null($person)) {
// LDAP ID - already in the DB for existing person, adding a new one for a new person
$person = Person::create(array('prsn_ldap_id' => Input::get('ldapId' . $entry->id)));
// NAME - already in the DB for existing person, adding a new one for a new person
$person->prsn_name = Input::get('userName' . $entry->id);
// PERSON STATUS
$person->prsn_status = Session::get('userStatus');
}
// If a person adds him/herself - update status from session to catch if it was changed in LDAP
if ($person->prsn_ldap_id == Session::get('userId')) {
$person->prsn_status = Session::get('userStatus');
$person->prsn_name = Session::get('userName');
}
}
// CLUB
// If club input is empty setting clubId to '-' (clubId 1).
// Else - look for a match in the Clubs DB and set person->clubId = matched club's id.
// No match found - creating a new club with title from input.
if (Input::get('club' . $entry->id) == '' or Input::get('club' . $entry->id) == '-') {
$person->clb_id = '1';
} else {
$match = Club::firstOrCreate(array('clb_title' => Input::get('club' . $entry->id)));
$person->clb_id = $match->id;
}
// COMMENT
// Change current comment to new comment
$entry->entry_user_comment = Input::get('comment' . $entry->id);
// Save changes to person and schedule entry
$person->updated_at = Carbon\Carbon::now();
$person->save();
$entry->prsn_id = $person->id;
$entry->save();
}
示例10: switch
<?php
$action = $_REQUEST['action'];
$handler->loadModel('people_m');
$person = new Person;
switch ($action){
case 'read':
echo $person->read($_POST);
break;
case 'create':
echo $person->create($_POST);
break;
case 'update':
echo $person->update($_POST);
break;
case 'destroy':
echo $person->destroy($_POST['data']);
break;
case 'edit':
echo $person->edit($_POST['id'],$_POST);
break;
}
?>
示例11: processView
function processView()
{
$GLOBALS['system']->includeDBClass('family');
$GLOBALS['system']->includeDBClass('person');
$GLOBALS['system']->includeDBClass('person_group');
$GLOBALS['system']->includeDBClass('congregation');
$GLOBALS['system']->includeDBClass('person_note');
if (!empty($_REQUEST['done'])) {
$this->_stage = 'done';
} else {
if (!empty($_POST['confirm_import'])) {
ini_set('memory_limit', '256M');
ini_set('max_execution_time', 60 * 10);
ini_set('zlib.output_compression', 'Off');
// read from session and create
$GLOBALS['system']->doTransaction('BEGIN');
$group = $GLOBALS['system']->getDBObject('person_group', $_SESSION['import']['groupid']);
$this->_captureErrors();
$done = 0;
?>
<h1 style="position: absolute; text-align: center; top: 40%; color: #ccc; width: 100%">Importing...</h1>
<div style="border: 1px solid; width: 50%; height: 30px; top: 50%; left: 25%; position: absolute"><div id="progress" style="background: blue; height: 30px; width: 2%; overflow: visible; line-height: 30px; text-align: center; color: white" /></div>
<p style="text-align: center; color: #888">If this indicator stops making progress, your import may still be running in the background.<br />You should <a href="<?php
echo build_url(array('view' => 'persons__list_all'));
?>
">check your system for the imported persons</a> before running the import again.</p>
<?php
foreach ($_SESSION['import']['families'] as $familydata) {
$members = $familydata['members'];
unset($familydata['members']);
$family = new Family();
$family->populate(0, $familydata);
if ($family->create()) {
foreach ($members as $persondata) {
$notetext = null;
if (!empty($persondata['note'])) {
$notetext = $persondata['note'];
unset($persondata['note']);
}
$person = new Person();
$person->populate(0, $persondata);
$person->setValue('familyid', $family->id);
if ($person->create()) {
$group->addMember($person->id);
if ($notetext) {
$note = new Person_Note();
$note->setValue('subject', 'Import note');
$note->setvalue('details', $notetext);
$note->setValue('personid', $person->id);
$note->create();
unset($note);
}
unset($person);
}
}
$done++;
if ($done % 20 == 0) {
?>
<script>var d = document.getElementById('progress'); d.innerHTML = 'Importing family <?php
echo $done . ' of ' . $_SESSION['import']['total_families'];
?>
'; d.style.width = '<?php
echo (int) ($done / $_SESSION['import']['total_families'] * 100);
?>
%'</script><?php
echo str_repeat(' ', 1024 * 4);
}
flush();
unset($family);
}
}
if ($errors = $this->_getErrors()) {
$msg = 'Errors during import - import aborted. <ul><li>' . implode('</li></li>', $errors) . '</li></ul>';
add_message($msg, 'failure', true);
$GLOBALS['system']->doTransaction('ROLLBACK');
} else {
add_message('Import complete', 'success');
$GLOBALS['system']->doTransaction('COMMIT');
}
?>
<script>document.location = '<?php
echo build_url(array());
?>
&done=1';</script>
<?php
exit;
} else {
if (!empty($_FILES['import'])) {
if (empty($_REQUEST['groupid'])) {
add_message("You must choose a group first", 'error');
$this->stage = 'begin';
return;
}
if (empty($_FILES['import']) || empty($_FILES['import']['tmp_name'])) {
add_message("You must upload a file", 'error');
return;
}
$this->_dummy_family = new Family();
$this->_dummy_person = new Person();
// read the csv and save to session
//.........这里部分代码省略.........
示例12: initPeople
private static function initPeople(Person $person)
{
$data = array('id' => 1, 'name' => 'Nelson', 'last_name' => 'Martell', 'genre_id' => 1);
$person->create();
$person->save($data);
return true;
}
示例13: createTestPerson
protected static function createTestPerson()
{
self::setTestApiKey();
self::randomizeFirstNameOfPerson();
return Person::create(self::$test_person);
}
示例14: readFromFile
/**
*
**/
public function readFromFile()
{
$marriageStack = array();
$file = fopen('FAMTREE.TXT', 'r');
while ($line = fgets($file)) {
// print $line . "\n";
if (strstr($line, ':')) {
// it's an attrib - parse it. add it.
list($attrName, $attrValue) = $currentPerson->addAttribute($line);
// SOME attributes pertain to the marriage, not the individual. detect this - apply as needed.
if ($attrName == 'TREEHINT') {
if ($attrValue == 'SUPPRESS_INDIVIDUAL') {
$currentPerson->suppress = 1;
} else {
if ($attrValue == 'SUPPRESS_UNION') {
$currentMarriage->suppress = 1;
} else {
echo "\n***ERROR: Unknown TREEHINT: " . $attrValue;
}
}
}
continue;
}
if (strstr($line, '>')) {
// print $line; // it's a person with lichauco blood
$gen = strpos($line, '>');
$ordinal = intval(ltrim(substr($line, 0, $gen)));
$pLine = substr($line, $gen + 1);
$currentPerson = Person::create($pLine);
$currentPerson->isSpouseRecord = 0;
$currentPerson->ordinal = $ordinal;
$gen2 = ($gen - 2) / 6 + 1;
// print $gen . " " . $gen2 . " " . $currentPerson->id . " " . $currentPerson->name;
// now set the union from which this guy came...
if ($gen2 > 1) {
// we're >1st gen. let's set the parent union
$currentPerson->cameFromUnion = $marriageStack[$gen2 - 1];
}
$this->personStack[$gen2] = $currentPerson;
} else {
// it's a person who married into the lichauco clan
// create the person. then create the union....
$gen = strpos($line, '^');
$ordinal = ord(substr($line, $gen - 1, 1)) - ord('a') + 1;
$pLine = substr($line, $gen + 1);
$currentPerson = $person2 = Person::Create($pLine);
$currentPerson->isSpouseRecord = 1;
$currentPerson->ordinal = $ordinal;
$gen2 = ($gen - 5) / 6 + 1;
// print $gen . " " . $gen2 . " " . $person2->id . " " . $person2->name;
$person1 = $this->personStack[$gen2];
// check if person2 is a dupe
if ($person2->id != Person::$theCount) {
// do any special processing for dupe here...
// TODO: find the marriage featuring person2->id and person1->id
$currentMarriage = Marriage::getExactMarriage($person1->id, $person2->id);
$person1->unions[] = $currentMarriage;
} else {
//print "\nAdding Marrage between " . $person1->name . " and " . $person2->name . " gen2 = " . $gen2;
$currentMarriage = Marriage::create($person1->id, $person2->id);
$marriageStack[$gen2] = $currentMarriage;
}
// add the union to the lichauco blood person...
$person1->unions[] = $currentMarriage;
}
}
fclose($file);
}
示例15: addOrUpdatePeople
private function addOrUpdatePeople($id, &$postedData){
$rtnmsg = 'Error';
try{
try{
$data = \Person::find($id);
}catch (\ActiveRecord\RecordNotFound $ex) {
$data = null;
}
if($postedData->type !== Menu::ppl_type_customer
&& $postedData->type !== Menu::ppl_type_supplier
&& $postedData->type !== Menu::ppl_type_contractor
){//&& $postedData->type !== Menu::ppl_type_receiver
$postedData->firstname = $data->name;
$postedData->lastname = $data->name;
}
if(!isset($postedData->mobile)){
$postedData->mobile = "";
}
if(!isset($postedData->mail)){
$postedData->mail = "";
}
$attributes = $this->getAttrForPeopleFromPost($data, $postedData);
if(is_null($data)){
$data = \Person::create($attributes);
$postedData->id = $id = $data->id;
}else{
$data->update_attributes($attributes);
}
$this->addOrUpdateLogins($id, $postedData);
$this->addorupdateLcnsAndPrsnAddr($id, $postedData);
$rtnmsg = 'Updated';
}
catch (\Slim\Exception $ex) {
$rtnmsg = "Error";
}
catch (\Exception $ex) {
$rtnmsg = 'Error';
}
return $rtnmsg;
}