本文整理汇总了PHP中Player::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::create方法的具体用法?PHP Player::create怎么用?PHP Player::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
DB::table('players')->delete();
Player::create(array('user_id' => 3, 'nom' => 'Bourdon', 'prenom' => 'Jean-Paul', 'nation_id' => 2, 'hcp' => 2.5, 'langue_id' => 1, 'club_id' => 2, 'statusplayer_id' => 1, 'sexe_id' => 1, 'naissance' => '1961-03-29', 'licence' => '344787'));
DB::table('managers')->delete();
Manager::create(array('user_id' => 2, 'nom' => 'Bourdon', 'prenom' => 'Jean-Paul', 'statussocial_id' => 2, 'numtva' => 'BE48-2525-5262', 'adr1' => 'Chss de Nivelles, 41-1', 'cpost' => '7181', 'ville' => 'Arquennes', 'nation_id' => 2, 'langue_id' => 1));
}
示例2: run
public function run()
{
DB::table('Players')->delete();
DB::table('Questions')->delete();
DB::table('Questionnaires')->delete();
DB::table('Answers')->delete();
$kim = Questionnaire::create(array('name' => 'kim'));
$frage1 = Question::create(array('question' => 'Das Spiel hat mir Spass gemacht', 'questionnaire_id' => $kim->id));
$playerJustus = Player::create(array('gender' => 'm', 'age' => '21', 'computer' => '4', 'game' => '3', 'questionnaire_id' => $kim->id));
$Testfrage = Answer::create(array('answer' => 'Test', 'player_id' => $playerJustus->id, 'question_id' => $frage1->id));
}
示例3: createUsersPlayersTest
public function createUsersPlayersTest($nbPlayer = 2)
{
// Set Php Time Out
ini_set('max_execution_time', 300);
//300 seconds = 5 minutes
// Suppression des Users & Players de Test
$deletedUsers = User::where('email', 'LIKE', '%aa.be')->delete();
// Boucle
$createdUsers = 0;
$messageRetour = '';
for ($u = 1; $u <= $nbPlayer; $u++) {
// 1-Auto Values
$autoNom = 'Player-' . $u;
$autoPrenom = 'player ' . $u;
$autoMail = 'player_' . $u . '@aa.be';
// 2-Create User with role = Player (3)
$user = new User();
$user->email = $autoMail;
$user->password = '1111';
$user->username = $autoNom;
$user->password_confirmation = '1111';
$user->confirmation_code = md5(uniqid(mt_rand(), true));
$user->confirmed = 1;
if (!$user->save()) {
$messageRetour .= 'Unable to create user ' . $user->email;
$messageRetour .= print_r($user->errors());
$messageRetour .= '<hr>';
} else {
$messageRetour .= $u . ' Created user ' . $user->email;
$messageRetour .= '<hr>';
$userRole = DB::table('roles')->where('name', '=', 'Player')->pluck('id');
$user->roles()->attach($userRole);
// 3-Create Player
$userId = $user->id;
$autoNation = rand(2, 4);
$autoHcp = rand(0, 360) / 10;
$autoLangue = rand(1, 3);
$autoClub = rand(2, 7);
$autosexe = rand(1, 2);
$autoLicence = 'TEST' . $u;
$year = rand(1950, 2006);
$month = rand(1, 12);
$day = rand(1, 28);
Player::create(array('user_id' => $userId, 'nom' => $autoNom, 'prenom' => $autoPrenom, 'nation_id' => $autoNation, 'hcp' => $autoHcp, 'langue_id' => $autoLangue, 'club_id' => $autoClub, 'statusplayer_id' => 1, 'sexe_id' => $autosexe, 'naissance' => Carbon::createFromDate($year, $month, $day), 'licence' => $autoLicence));
$createdUsers++;
}
}
return $messageRetour;
}
示例4: doAddPlayer
public function doAddPlayer($data, Form $form)
{
$player_exists = Player::get()->filter(array('FirstName' => $data['FirstName'], 'Surname' => $data['Surname']))->count() > 0 ? true : false;
if ($player_exists) {
// todo
// add error message because player already exists
return $this->redirectBack();
} else {
$player = Player::create();
$player->FirstName = $data['FirstName'];
$player->Surname = $data['Surname'];
$player->write();
$redirectLink = $this->Link() . '?success=1';
return $this->redirect($redirectLink);
}
}
示例5: createRotter
function createRotter($team_id, $race, $nr)
{
global $DEA;
$pos_id = $DEA[$race]['players']['Rotter']['pos_id'];
list($exitStatus, $pid) = Player::create($input = array('nr' => $nr, 'f_pos_id' => $pos_id, 'team_id' => $team_id, 'name' => "Rotter" . $nr), $opts = array('free' => true, 'force' => true));
if (!$exitStatus == Player::T_CREATE_SUCCESS) {
$this->error = "Failed to add a rotter to the roster.";
return false;
}
return true;
}
示例6: dirname
<?php
namespace bmtmgr;
require_once dirname(__DIR__) . '/src/common.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_get_params(['club_id', 'season_id']);
utils\require_post_params(['firstname', 'lastname', 'gender']);
$season = Season::by_id($_GET['season_id']);
$club = User::by_id($_GET['club_id']);
$name = \sprintf('%s, %s', $_POST['lastname'], $_POST['firstname']);
$textid = \str_replace(' ', '_', $club->name . '-' . $_POST['firstname'] . ' ' . $_POST['lastname']);
try {
$player = Player::create($season->id, $club->id, $textid, $name, $_POST['gender']);
$player->save();
} catch (utils\DuplicateEntryException $e) {
render_ajax_error(sprintf('Ein Spieler mit der Id "%s" existiert bereits', $textid));
exit;
}
render_ajax('season/' . $season->id . '/club/' . $club->id . '/', ['player' => $player]);
示例7: __construct
public function __construct($player1Name, $player2Name)
{
$this->players[0] = $this->players[$player1Name] = Player::create($player1Name);
$this->players[1] = $this->players[$player2Name] = Player::create($player2Name);
$this->scoreTranslator = new ScoreTranslator();
}
示例8: _handleActions
private function _handleActions($ALLOW_EDIT)
{
global $coach;
$team = $this;
// Copy. Used instead of $this for readability.
// No request sent?
if (!isset($_POST['type']) || !$ALLOW_EDIT) {
return false;
}
// Handle request.
if (get_magic_quotes_gpc()) {
$_POST['name'] = stripslashes(isset($_POST['name']) ? $_POST['name'] : '');
$_POST['skill'] = stripslashes(isset($_POST['skill']) ? $_POST['skill'] : '');
$_POST['thing'] = stripslashes(isset($_POST['thing']) ? $_POST['thing'] : '');
$_POST['teamtext'] = stripslashes(isset($_POST['teamtext']) ? $_POST['teamtext'] : '');
$_POST['txt'] = stripslashes(isset($_POST['txt']) ? $_POST['txt'] : '');
}
$p = isset($_POST['player']) && $_POST['type'] != 'hire_player' ? new Player($_POST['player']) : null;
switch ($_POST['type']) {
case 'hire_player':
list($exitStatus, $pid) = Player::create(array('nr' => $_POST['number'], 'f_pos_id' => $_POST['player'], 'team_id' => $team->team_id, 'name' => $_POST['name']), array('JM' => isset($_POST['as_journeyman']) && $_POST['as_journeyman']));
status(!$exitStatus, $exitStatus ? Player::$T_CREATE_ERROR_MSGS[$exitStatus] : null);
break;
case 'hire_journeyman':
status($p->hireJourneyman());
break;
case 'fire_player':
status($p->sell());
break;
case 'unbuy_player':
status($p->unbuy());
break;
case 'rename_player':
status($p->rename($_POST['name']));
break;
case 'renumber_player':
status($p->renumber($_POST['number']));
break;
case 'rename_team':
status($team->rename($_POST['name']));
break;
case 'buy_goods':
status($team->buy($_POST['thing']));
break;
case 'drop_goods':
status($team->drop($_POST['thing']));
break;
case 'ready_state':
status($team->setReady(isset($_POST['bool'])));
break;
case 'retire':
status(isset($_POST['bool']) && $team->setRetired(true));
break;
case 'delete':
status(isset($_POST['bool']) && $team->delete());
break;
case 'skill':
$type = null;
$p->setChoosableSkills();
if (in_array($_POST['skill'], $p->choosable_skills['norm'])) {
$type = 'N';
} elseif (in_array($_POST['skill'], $p->choosable_skills['doub'])) {
$type = 'D';
} else {
$type = 'C';
}
# Assume it's a characteristic.
status($p->addSkill($type, $type == 'C' ? (int) str_replace('ach_', '', $_POST['skill']) : (int) $_POST['skill']));
break;
case 'teamtext':
status($team->saveText($_POST['teamtext']));
break;
case 'news':
status($team->writeNews($_POST['txt']));
break;
case 'newsdel':
status($team->deleteNews($_POST['news_id']));
break;
case 'newsedit':
status($team->editNews($_POST['news_id'], $_POST['txt']));
break;
case 'pic':
if ($_POST['add_del'] == 'add') {
if ($_POST['pic_obj'] == IMGTYPE_TEAMSTADIUM) {
list($status, $msg) = $team->saveStadiumPic(ImageSubSys::$defaultHTMLUploadName . '_stad');
status($status, !$status ? $msg : '');
} elseif ($_POST['pic_obj'] == IMGTYPE_TEAMLOGO) {
list($status, $msg) = $team->saveLogo(ImageSubSys::$defaultHTMLUploadName . '_logo');
status($status, !$status ? $msg : '');
}
} else {
if ($_POST['pic_obj'] == IMGTYPE_TEAMSTADIUM) {
status($team->deleteStadiumPic());
} elseif ($_POST['pic_obj'] == IMGTYPE_TEAMLOGO) {
status($team->deleteLogo());
}
}
break;
}
// Administrator tools used?
//.........这里部分代码省略.........
示例9: signUp
public static function signUp($username, $password)
{
$mysqli = new mysqli("classroom.cs.unc.edu", "zrkaplan", "KMP4president", "zrkaplandb");
$mysqli->real_escape_string($username);
$mysqli->real_escape_string($password);
$result = $mysqli->query("select * from Player where username = '" . $username . "'");
if ($result->num_rows === 0) {
return Player::create($username, $password);
}
return null;
}
示例10: create_object
public function create_object($data)
{
$agent = Agent::mapper()->create_object(array('id' => $data['agent'], 'alias' => $data['agent_alias'], 'avatar' => $data['agent_avatar']));
return Player::create(array('id' => $data['id'], 'agent' => $agent, 'target' => $data['target'], 'credits' => $data['credits'], 'pkn' => $data['pkn'], 'status' => $data['status']));
}
示例11: Rank
checkclash('igs', $igs);
$player->Rank = new Rank($rank);
$player->Club = new Club($club);
$player->Email = $email;
$player->OKemail = $okem;
$player->Trivia = $trivia;
$player->Phone = $phone;
$player->KGS = $kgs;
$player->IGS = $igs;
$player->Userid = $userid;
$player->Notes = $notes;
$player->Latestcall = $latest == "None" ? "" : $latest;
if ($joinil) {
$player->ILdiv = assign_ildiv($rank);
}
$player->create();
// If no password specified, invent one
if (strlen($passw) == 0) {
$passw = generate_password();
}
$player->set_passwd($passw);
newaccemail($email, $userid, $passw);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<?php
$Title = "New account {$userid} created OK";
include 'php/head.php';
?>
<body>
<script language="javascript" src="webfn.js"></script>
示例12: _locationsByIdAndRank
/**
* Based on a Location, retrieve the local rankings
* @param int $id the unique identifier of the location
* @param string|RankingId $rank the kind of ranking you want to retrieve.
* Based on Clans and based on players is supported at the moment.
* @return The clans/player who are located at the location id
*/
private function _locationsByIdAndRank(int $id, $rank)
{
$curlClient = curl_init(self::BASE_URL . self::LOCATIONS_URL . '/' . $id . '/rankings/' . $rank);
curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader);
curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true);
$results = json_decode(curl_exec($curlClient), true);
$items = [];
foreach ($results['items'] as $result) {
if ($rank === RankingId::CLANS) {
$items[] = Clan::create($result);
} else {
$items[] = Player::create($result);
}
}
return $items;
}
示例13: list
# Add team
list($exitStatus, $tid) = Team::create(array_merge(array_intersect_key((array) $t, array_fill_keys(Team::$createEXPECTED, null)), array_combine(array_keys($map), array_values(array_intersect_key((array) $t, array_fill_keys(array_values($map), null))))));
status(!$exitStatus, $exitStatus ? Team::$T_CREATE_ERROR_MSGS[$exitStatus] : "Created team '{$t->name}'");
# Add players
$ROLLBACK = false;
if (is_numeric($tid) && !$exitStatus) {
$team = new Team($tid);
foreach ($t->players->player as $p) {
$p = (object) (array) $p;
# Get rid of SimpleXML objects.
if (!$team->isPlayerPosValid($p->pos_id)) {
status(false, "Invalid race position ID '{$p->pos_id}' for '{$p->name}'");
$ROLLBACK = true;
break;
}
list($status1, $pid) = Player::create(array('nr' => $p->nr, 'f_pos_id' => $p->pos_id, 'name' => $p->name, 'team_id' => $tid), array('force' => true, 'free' => true));
if ($status1) {
status(false, Player::$T_CREATE_ERROR_MSGS[$status1]);
break;
}
$status2 = true;
# The status must be set as the "inj" (not agn) field for EVERY match (import) entry.
# This is because MySQL may pick a random match data entry from which to get the status from.
$pstatus = $T_INJS_REV[strtoupper($p->status)];
# Injuries
foreach (array('ma', 'st', 'ag', 'av', 'ni') as $inj) {
$agn = $T_INJS_REV[strtoupper($inj)];
while ($p->{$inj}-- > 0) {
$status2 &= Match::ImportEntry($pid, array_merge(array_fill_keys(array_merge($T_PMD_ACH, $T_PMD_IR), 0), array_combine($T_PMD_INJ, array($pstatus, $agn, $p->{$inj}-- > 0 ? $agn : NONE))));
}
}
示例14: create
/**
* Creates a clan object with the given data
* @param array $data an associative array to fill up the members of the
* clan class
* @return Clan a clan object with the data given as it's members
*/
public static function create(array $data) : Clan
{
$clan = new Clan();
parent::fill($data, $clan);
if (is_array($clan->location)) {
$clan->location = Location::create($clan->location);
}
if (is_array($clan->memberList)) {
$members = [];
foreach ($clan->memberList as $member) {
$members[] = Player::create($member);
}
$clan->memberList = $members;
}
return $clan;
}
示例15: _create_player
protected function _create_player($agent_id)
{
$player = Player::create(array('agent' => $agent_id, 'game' => $this->id, 'status' => 1, 'credits' => 0, 'target' => -1, 'pkn' => str_pad(mt_rand(0, 9999), 4, "0")));
$this->_storage->save($player);
return $player;
}