本文整理汇总了PHP中Team::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Team::save方法的具体用法?PHP Team::save怎么用?PHP Team::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Team
的用法示例。
在下文中一共展示了Team::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
* POST /team
*
* @return Response
*/
public function store()
{
//get current club
$user = Auth::user();
$club = $user->Clubs()->FirstOrFail();
$uuid = Uuid::generate();
$validator = Validator::make(Input::all(), Team::$rules);
if ($validator->passes()) {
$team = new Team();
$team->id = $uuid;
$team->name = Input::get('name');
$team->season_id = Input::get('season_id');
$team->program_id = Input::get('program_id');
$team->description = Input::get('description');
$team->early_due = Input::get('early_due');
$team->early_due_deadline = Input::get('early_due_deadline');
$team->due = Input::get('due');
$team->plan_id = Input::get('plan_id');
$team->open = Input::get('open');
$team->close = Input::get('close');
$team->max = Input::get('max');
$team->status = Input::get('status');
$team->club_id = $club->id;
$team->allow_plan = 1;
$status = $team->save();
if ($status) {
return Redirect::action('TeamController@index')->with('messages', 'Program created successfully');
} else {
$error = $status->errors()->all(':message');
return Redirect::back()->withInput()->withErrors($error);
}
}
$error = $validator->errors()->all(':message');
return Redirect::back()->withErrors($error)->withInput();
}
示例2: store
/**
* Store a newly created resource in storage.
* POST /group
*
* @return Response
*/
public function store($id)
{
//create sub team
//return Redirect::action('SubController@create',$id)->with( 'notice', 'This action cannot be perform at this moment, please comeback soon.');
$user = Auth::user();
$club = $user->clubs()->FirstOrFail();
$parent_team = Team::find($id);
$uuid = Uuid::generate();
$validator = Validator::make(Input::all(), Team::$rules_group);
if ($validator->passes()) {
$team = new Team();
$team->id = $uuid;
$team->name = Input::get('name');
$team->season_id = $parent_team->season_id;
$team->program_id = $parent_team->program_id;
$team->description = $parent_team->description;
$team->early_due = $parent_team->getOriginal('early_due');
$team->early_due_deadline = $parent_team->early_due_deadline;
$team->due = $parent_team->getOriginal('due');
$team->plan_id = $parent_team->plan_id;
$team->open = $parent_team->open;
$team->close = $parent_team->close;
$team->max = Input::get('max');
$team->status = $parent_team->getOriginal('status');
$team->parent_id = $parent_team->id;
$team->club_id = $club->id;
$team->allow_plan = 1;
$status = $team->save();
if ($status) {
return Redirect::action('TeamController@show', $parent_team->id)->with('messages', 'Group created successfully');
}
}
$error = $validator->errors()->all(':message');
return Redirect::action('SubController@create', $id)->withErrors($validator)->withInput();
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Team();
$model->attributes = $_POST;
$result = $model->save();
$this->sendAjaxResponse($model);
}
示例4: createByName
public function createByName($name)
{
print_r('[' . $name . ']');
$document = new Team();
$document->setName($name);
$document->setSlug();
$document->save();
$document = $this->findOneBySlug($document->getSlug());
return $document;
}
示例5: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Team();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Team'])) {
$model->attributes = $_POST['Team'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(create_team_request $request)
{
//
$newName = md5($request->file('image')) . $request->file('image')->getClientOriginalName();
$path = 'teams';
$request->file('image')->move($path, $newName);
$teamDb = new Team();
$teamDb->name = $request->input('name');
$teamDb->content = $request->input('content');
$teamDb->image = $newName;
$teamDb->save();
return redirect('team');
}
示例7: getOrCreateTeam
protected function getOrCreateTeam($name, $nickname)
{
$nickname = trim($nickname);
$name = trim(str_replace($nickname, '', $name));
$slug = $this->CI->slugify->simple($name);
$team = $this->CI->_team->findOneBySlug($slug);
if (!$team) {
$team = new Team();
$team->setName($name);
$team->setNickname($nickname);
$team->save();
}
return $team;
}
示例8: store
public static function store()
{
$params = $_POST;
$Team = new Team(array('name' => $params['name'], 'year' => $params['year'], 'city' => $params['city']));
$errors = $Team->errors();
if (count($errors) != 0) {
View::make('/Team/new.html', array('errors' => $errors, 'team' => $Team));
} else {
$Team->save();
$player = self::get_user_logged_in();
$m = new Teammember(array('player_id' => $player->id, 'team_id' => $Team->id));
$m->save();
Redirect::to('/team/' . $Team->id, array('message' => 'Joukkue luotu!'));
}
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$rules = ['teamname' => 'required'];
//validation
$validation = Validator::make(Input::all(), $rules);
if ($validation->passes()) {
$team = new Team();
$team->teamname = Input::get('teamname');
$team->save();
// redirect
Session::flash('message', 'Successfully created team Owners!');
return Redirect::to('view');
//return View::make('pages.register')->with('message', 'team created');
}
return Redirect::back()->withErrors($validation)->withInput();
}
示例10: newteam
function newteam($data)
{
if ($data['name'] && $data['email'] && $data['country_id'] && $data['submiter']) {
$newteam = new Team();
$newteam->name = sqlite_escape_string($data['name']);
$newteam->description = sqlite_escape_string($data['description']);
$newteam->email = sqlite_escape_string($data['email']);
$newteam->homepage = sqlite_escape_string($data['homepage']);
$newteam->mailinglist = sqlite_escape_string($data['mailinglist']);
$newteam->irc = sqlite_escape_string($data['irc']);
$newteam->location = sqlite_escape_string($data['location']);
$newteam->country_id = sqlite_escape_string($data['country_id']);
$newteam->submiter = sqlite_escape_string($data['submiter']);
$newteam->save();
return true;
} else {
return false;
}
}
示例11: postCreate
/**
* Creates our section when POSTed to. Performs snazzy validation.
* @return [type] [description]
*/
public function postCreate()
{
$rules = array('name' => 'required|max:255|unique:teams', 'tag' => 'required|max:255', 'upload-logo' => 'max:2500');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::action('Admin_TeamsController@getCreate')->withInput()->withErrors($validator);
} else {
$team = new Team();
$team->name = Input::get('name');
$team->tag = Input::get('tag');
if (Input::hasFile('upload-logo')) {
$logofile = Input::file('upload-logo');
$logofileext = $logofile->getClientOriginalExtension();
$logo_name = "Team_" . Str::limit(md5(Input::get('name')), 10, false) . '-' . Str::limit(md5(time()), 10, false) . "_" . Str::slug(Input::get('name')) . "." . $logofileext;
$logofile->move($this->dir, $logo_name);
$team->logo = $logo_name;
}
$team->save();
return Redirect::action('Admin_TeamsController@getIndex');
}
}
示例12: load
public function load()
{
$this->clear();
// Miami Hurricanes
$team = new Team('Miami, FL');
$team->setOfficialName('University of Miami');
$team->setNickname('Hurricanes');
$team->setCity('Miami');
$team->setState('FL');
$team->setNcaaId(415);
$level = $this->CI->_level->findOneBySlug('college');
$team->setLevel($level);
$league = $this->CI->_league->findOneBySlug('ncaa');
$team->setLeague($league);
$division = $this->CI->_division->findOneBySlug('d1');
$team->setDivision($division);
$conference = $this->CI->_conference->findOneBySlug('atlantic-coast');
$team->setConference($conference);
$team->save();
print_r(sprintf("Created Team: %s (%s)\n", $team->getName(), $team->getId()));
// Maryland Terrapins
$team = new Team('Maryland');
$team->setOfficialName('University of Maryland');
$team->setNickname('Terrapins');
$team->setCity('College Park');
$team->setState('FL');
$team->setNcaaId(392);
$level = $this->CI->_level->findOneBySlug('college');
$team->setLevel($level);
$league = $this->CI->_league->findOneBySlug('ncaa');
$team->setLeague($league);
$division = $this->CI->_division->findOneBySlug('d1');
$team->setDivision($division);
$conference = $this->CI->_conference->findOneBySlug('atlantic-coast');
$team->setConference($conference);
$team->save();
print_r(sprintf("Created Team: %s (%s)\n", $team->getName(), $team->getId()));
}
示例13: updateTeams
public function updateTeams()
{
$aPoules = Poule::getAll(array('season_nefub_id' => Season::getInstance()->nefub_id), 'competition_nefub_id');
foreach ($aPoules as $oPoule) {
$aPouleTeams = $oPoule->getPouleTeams();
foreach ($aPouleTeams as $oPouleTeam) {
$team = $this->getAPITeamDetails($oPouleTeam->team_nefub_id);
$oTeam = Team::getByNefubId($team->ID);
if (!$oTeam) {
$oTeam = new Team();
$oTeam->nefub_id = $team->ID;
$oTeam->name = $team->Name;
$oTeam->competition_nefub_id = $oPoule->competition_nefub_id;
$oTeam->season_nefub_id = $oPoule->getCompetition()->season_nefub_id;
$oTeam->club_nefub_id = $team->Club->ID;
$oTeam->color_shirt = $team->Dress->Shirt;
$oTeam->color_shorts = $team->Dress->Short;
self::put('Team ' . $team->Name . ' toegevoegd');
$oTeam->save();
}
if (isset($team->Players) && is_array($team->Players)) {
foreach ($team->Players as $teamPlayer) {
$this->convertTeamPerson($teamPlayer, $oTeam);
}
} else {
self::put('Geen spelers gevonden voor ' . $team->Name);
}
$this->retrieveClub($team->Club);
$this->retrieveTeamGames($team, 'schedule');
$query = "SELECT COUNT(Game.nefub_id) as countGames\n\t\t\t\t\t\t\tFROM Game\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t(team1_nefub_id = '" . $team->ID . "'\n\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\tteam2_nefub_id = '" . $team->ID . "')\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\tGame.date <= CURDATE()";
$rows = Database::select_rows_by_query($query);
$playedGames = $rows[0]['countGames'];
$bRetrieveResults = false;
if ($playedGames) {
// Als er geen oude wedstrijden in de DB staan, vermoedelijk zijn ze dan niet eerder opgehaald.
$query .= " AND Game.actions_retrieved = 0";
$rows = Database::select_rows_by_query($query);
$gamesToRetrieve = $rows[0]['countGames'];
$bRetrieveResults = $gamesToRetrieve != 0;
}
if ($bRetrieveResults) {
$this->retrieveTeamGames($team, 'results');
} else {
self::put('Resultaten voor ' . $oTeam->name . ' hoeven niet vernieuwd te worden');
}
$oTeam->save();
$this->retrievedTeamNefubIds[$oPouleTeam->team_nefub_id] = true;
}
}
}
示例14: actionTeams
public function actionTeams($id)
{
$model = $this->loadModel($id);
$players = $model->players;
if (isset($_POST['Teams']['info'])) {
$error = false;
$data = CJSON::decode($_POST['Teams']['info']);
foreach ($data['players'] as $key => $player) {
$_player = PlayerTournament::model()->findByPk($player['id']);
$_player->chip_pulled = $player['chip_pulled'];
if (!$_player->save()) {
$error = true;
}
$team = new Team();
$team->tournament_id = $id;
$team->player_id = $player['player_id'];
$team->position = $player['chip_pulled'];
if (!$team->save()) {
$error = true;
}
}
$teams = $model->get_teams();
//echo "<pre>";print_r($teams);echo "</pre>";exit;
$max_teams = Team::model()->findAllByAttributes(array('tournament_id' => $model->id), array('order' => 'position DESC'));
$c = new ChallongeAPI(Yii::app()->params['challonge_api']);
foreach (range(1, $max_teams[0]->position) as $position) {
$params = array("participant[name]" => $model->get_team_name($position), "participant[seed]" => $position);
$participant = $c->createParticipant($model->challonge_id, $params)->participant;
if ($participant) {
Team::model()->updateAll(array('challonge_participant_id' => $participant->id), "tournament_id = {$model->id} and position = {$position}");
}
}
if (!$error) {
Yii::app()->user->setFlash('success', 'Teams saved.');
$this->redirect(array('teams', 'id' => $id));
}
$message = "";
foreach ($_player->getErrors() as $error) {
$message .= $error . "<br />";
}
Yii::app()->user->setFlash('error', $message);
}
$this->render('teams', array('model' => $model, 'players' => $players, 'registered_players' => $model->registered_players(), 'teams' => $model->get_teams()));
}
示例15: createteam
public function createteam($aData)
{
if ($this->samePlayer($aData['teammate1_id'], $aData['teammate2_id'])) {
throw new Exception('Musisz wybrać dwóch różnych zawodników!');
}
if ($this->checkIfTeamExists($aData['Tournaments_id'], $aData['teammate1_id'], $aData['teammate2_id'])) {
throw new Exception('Nie można dodać takiej drużyny do tego turnieju!');
}
$tour = $this->getTable()->find($aData['Tournaments_id']);
$player1 = Player::getPlayerById($aData['teammate1_id']);
$player2 = Player::getPlayerById($aData['teammate2_id']);
if (!$this->checkTournament($player1->gender, $player2->gender, $tour->kind)) {
throw new Exception('Rodzaj turnieju nie pozwala na zestawienie takiego zespołu. Wybierz do turnieju męskiego dwie pary męskie, do żeńskiego dwie pary kobiece, a do mieszanego parę mieszaną.');
}
$team = new Team();
$team->Tournaments_id = (int) $aData['Tournaments_id'];
$team->teammate1_id = (int) $aData['teammate1_id'];
$team->teammate2_id = (int) $aData['teammate2_id'];
$team->enrolled = new Doctrine_Expression('NOW()');
$team->save();
$countTeams = $tour->Teams->count();
if ($countTeams) {
$countTeams *= 10;
$tour->rank = $countTeams;
$tour->save();
}
}