/** * 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(); }
/** * 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(); }
/** * 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); }
public function createByName($name) { print_r('[' . $name . ']'); $document = new Team(); $document->setName($name); $document->setSlug(); $document->save(); $document = $this->findOneBySlug($document->getSlug()); return $document; }
/** * 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)); }
/** * 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'); }
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; }
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!')); } }
/** * 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(); }
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; } }
/** * 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'); } }
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())); }
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; } } }
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())); }
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(); } }
public function postStepThree() { $code = Input::get('code'); $validation = Validator::make(['teamname' => Input::get('teamname')], ['teamname' => 'required|max:20|min:4']); if ($validation->fails()) { return Redirect::route('setprofile_step3', array($code))->withErrors($validation)->withInput(Input::except('_token')); } else { $teamname = Input::get('teamname'); try { $userQuery = User::where('code', '=', $code)->first(); $creatorID = $userQuery->id; $orgIDQuery = DB::table('organizations')->where('creator_id', '=', $creatorID)->first(); $orgID = $orgIDQuery->id; if ($userQuery && $orgIDQuery) { $team = new Team(); $team->team_title = $teamname; $team->leader_id = $creatorID; $team->org_id = $orgID; $team->save(); $teamQuery = Team::where('team_title', '=', $teamname)->first(); $teamID = $teamQuery->id; $userQuery->team_id = $teamID; $userQuery->save(); return Redirect::route('setprofile_step4', array($code)); } else { return 'Cant Find User'; } } catch (Exception $e) { return Redirect::route('setprofile_step3', array($code)); } } }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aDealer !== null) { if ($this->aDealer->isModified() || $this->aDealer->isNew()) { $affectedRows += $this->aDealer->save($con); } $this->setDealer($this->aDealer); } if ($this->aTeam !== null) { if ($this->aTeam->isModified() || $this->aTeam->isNew()) { $affectedRows += $this->aTeam->save($con); } $this->setTeam($this->aTeam); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } if ($this->dealerTeamVersionsScheduledForDeletion !== null) { if (!$this->dealerTeamVersionsScheduledForDeletion->isEmpty()) { \DealerTeam\Model\DealerTeamVersionQuery::create()->filterByPrimaryKeys($this->dealerTeamVersionsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->dealerTeamVersionsScheduledForDeletion = null; } } if ($this->collDealerTeamVersions !== null) { foreach ($this->collDealerTeamVersions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Team(); $catCategory = new Category(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Team'])) { $model->attributes = $_POST['Team']; $model->CREATION_DATE = date("Y-m-d H:i:s"); if ($model->save()) { $this->redirect(array('view', 'id' => $model->ID)); } } $this->render('create', array('model' => $model, 'catCategory' => $catCategory)); }
public function insertTeam() { $rules = array('name' => 'required', 'imglogo' => 'required', 'imgjersey' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('admin/addteam')->withErrors($validator)->withInput(); } else { $name = Input::get('name'); $imagelogo = explode('/', Input::get('imglogo')); $imagelogo = urldecode(end($imagelogo)); $extensionlogo = explode(".", $imagelogo); $extensionlogo = end($extensionlogo); $imagejersey = explode('/', Input::get('imgjersey')); $imagejersey = urldecode(end($imagejersey)); $extensionjersey = explode(".", $imagejersey); $extensionjersey = end($extensionjersey); $imglogo = Image::make('files/' . $imagelogo); $imglogo->resize(160, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->save('files/' . $imagelogo); $newnamelogo = date('YmdHis') . '_' . Str::slug($name, '_') . '.' . $extensionlogo; File::move('files/' . $imagelogo, 'teams/' . $newnamelogo); $imgjersey = Image::make('files/' . $imagejersey); $imgjersey->resize(160, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->save('files/' . $imagejersey); $newnamejersey = date('YmdHis') . '_' . Str::slug($name, '_') . '.' . $extensionjersey; File::move('files/' . $imagejersey, 'jerseys/' . $newnamejersey); $team = new Team(); $team->name = Input::get('name'); $team->type = Input::get('type'); $team->logo_image = $newnamelogo; $team->jersey_image = $newnamejersey; $team->save(); Session::flash('success', 'New team added'); return Redirect::to('admin/teams'); } }
function update($vars, &$errors) { //reset team lead if they're being deleted if ($this->getLeadId() == $vars['lead_id'] && $vars['remove'] && in_array($this->getLeadId(), $vars['remove'])) { $vars['lead_id'] = 0; } //Save the changes... if (!Team::save($this->getId(), $vars, $errors)) { return false; } //Delete staff marked for removal... if ($vars['remove']) { $sql = 'DELETE FROM ' . TEAM_MEMBER_TABLE . ' WHERE team_id=' . db_input($this->getId()) . ' AND staff_id IN (' . implode(',', db_input($vars['remove'])) . ')'; db_query($sql); } //Reload. $this->reload(); return true; }
<?php require_once 'init.php'; use Agil\View\View; use Agil\Helpers\Slugify; use Agil\Session\Session; $request = View::route($_POST); if ($request['METHOD'] == 'POST' && !empty($request['name']) && Session::exist('logado') || !empty($request['website'])) { $pk = $request['pk']; $logado = Session::get('logado'); $name = $request['name']; $website = $request['website']; $slug = Slugify::toSlug($name); $fields = array('id_project' => $pk, 'id_admin' => $logado['id_member'], 'name' => $name, 'website' => $website, 'slug' => $slug); $model = new Team($fields); $team = $model->save(); if ($team) { ?> <script> var timePopup = setTimeout(function(){ window.parent.boss.removeClass('modal_dialog', 'active'); window.parent.boss.ajax.load('/app/team/view_team/?pk=<?php echo $pk; ?> ', '#app_pane_body'); }, 100); window.parent.boss.popup("Sucesso ao criar equipe."); </script> <?php } else { ?>