/**
  * Destroy the given team.
  *
  * @param  Request  $request
  * @param  Team  $team
  * @return Response
  */
 public function destroy(Request $request, $team)
 {
     $this->teamRepo->isTeamForUser($request->user(), $team);
     $teamDelete = Team::find($team);
     if (!$teamDelete) {
         abort(404);
     }
     $this->authorize('destroy', $teamDelete);
     $teamDelete->delete();
     return redirect()->route('teams.index')->with('status', 'success')->with('message', 'Equipo eliminado correctamente. ¿No te gustaba?, ¿Estaba mal creado? Espero que nos ayudes');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($team_id)
 {
     $team = Team::find($team_id);
     if (!$team) {
         abort(404);
     }
     $message = "" . $team->name . " ha dejado de ser un equipo favorito. ¿Por qué?";
     session_start();
     $registro = Rating::where('team_id', '=', $team_id)->where('session', '=', $_SESSION["session"])->get();
     $registro[0]->delete();
     return redirect()->route('welcome')->with('status', 'danger')->with('message', $message);
 }
 public function addPoints(Request $request, $id)
 {
     $this->validate($request, ['amount' => 'required|numeric']);
     $team = Team::find($id);
     foreach ($team->users as $user) {
         $points = new \App\Point();
         $points->user_id = $user->id;
         $points->amount = $request->input('amount');
         $points->note = $request->input('note');
         $points->save();
     }
     return $this->response();
 }
 public function isTeamForUser(User $user, $team_id)
 {
     $equipo = Team::find($team_id);
     if (!$equipo) {
         abort(404);
     }
     if ($user->role === 'app_admin') {
         return true;
     }
     if ($equipo->user->id === $user->id) {
         return true;
     } else {
         //unauthorized
         abort(401);
     }
 }
 public function Show($id, $libdivision)
 {
     $team = Team::find($id);
     if ($team != null && str_slug($team->libdivision) == $libdivision) {
         $tableau = array();
         $libelle = '';
         foreach ($team->Rounds as $round) {
             if (isset($tableau[$round->libelle])) {
                 $tableau[$round->libelle][] = $round;
             } else {
                 $tableau[$round->libelle] = array($round);
             }
         }
         return view('front.championship.show', array('rounds' => $tableau, 'ranks' => $team->Ranks));
     } else {
         abort(404);
     }
 }
Beispiel #6
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $title = "Dashboard";
     if (Auth::user()->role_id == 4) {
         $model = Department::with(['user', 'developer', 'leader', 'manager'])->get();
         return view('html.dashboard.admin', compact('title', 'model'));
     } elseif (Auth::user()->role_id == 3) {
         return view('html.dashboard.manager', compact('title', 'model'));
     } elseif (Auth::user()->role_id == 2) {
         $list = \App\Team::where('created_user_id', Auth::user()->id)->with('detail')->first();
         return view('html.dashboard.leader', compact('title', 'list'));
     } else {
         $var = \App\TeamDetail::select('team_id')->where('staff_id', Auth::user()->id)->first();
         $bol = "";
         if ($var != null) {
             $team = \App\Team::find($var->team_id);
             $leader = User::find($team->created_user_id);
             $bol = "true";
             $list = \App\TeamDetail::select('*')->where('staff_id', '<>', Auth::user()->id)->where('team_id', $var->team_id)->get();
         }
         return view('html.dashboard.developer', compact('title', 'list', 'bol', 'leader'));
     }
 }
 public function destroy($id, $user)
 {
     $team = Team::find($id);
     if ($team->created_user_id != Auth::user()->id) {
         return view('html.error-403');
     }
     \App\TeamDetail::where(['team_id' => $id, 'staff_id' => $user])->delete();
     return redirect()->route('admin.team.index')->with('success', 'successfully deleted');
 }
 public function postNewAnggota(UpdateAnggotaRequest $request)
 {
     $team = Team::find($request['id']);
     User::create(['nama' => $request['nama'], 'email' => $request['email'], 'notelp' => '62' . $request['notelp'], 'idteam' => $request['id']]);
     return redirect('admin/team/anggota/' . $request['id'])->with('status', 'Anggota sudah di tambah');
 }
 /**
  * Get the team2 of a match.
  * @return App/Team
  */
 public function team2()
 {
     return Team::find($this->team2_id);
 }
Beispiel #10
0
 public function applyToCourse(Request $request)
 {
     $this->validate($request, ['team' => 'required|integer|exists:teams,id', 'course' => 'required|integer|exists:courses,id']);
     $team = Team::find($request->input('team'));
     $course = Course::find($request->input('course'));
     $team->courses()->attach($course);
     Session::flash('success', "Your team applied to {$course->name}");
     return redirect()->back();
 }
Beispiel #11
0
 public function initTeam()
 {
     $intPlayerId = Input::get('player_id', 0);
     // 目前已经生成Team数量确认
     /* 玩家可用Team数量确认
      * Lv.1 ~ Lv.10   1Team
      * Lv.11 ~ Lv.20  2Team
      * Lv.21 ~ Lv.50  3Team
      * Lv.51 ~ Lv.100 4Team
      * 氪金玩家        +1Team
      */
     $objTeam = new Team();
     $objTeam->player_id = $intPlayerId;
     $objTeam->team_no = 1;
     // 该用户的第一个队伍
     $objTeam->team_name = "Team01";
     $firstCard = OwnedCard::where('player_id', $intPlayerId)->orderBy('id', 'ASC')->first();
     $objTeam->position_1_owned_card_id = $firstCard->id;
     $objTeam->total_cost = $firstCard->getCost();
     $objTeam->save();
     $objTeamBk = Team::find($objTeam->id);
     // 20151012 TeamMember Table 初始化
     for ($intPosition = 1; $intPosition <= 6; $intPosition++) {
         $objTeamMember = new TeamMember();
         $objTeamMember->team_id = $objTeamBk->id;
         $objTeamMember->position = $intPosition;
         $objTeamMember->player_id = $objTeamBk->player_id;
         if ($intPosition == 1) {
             $objTeamMember->card_id = $firstCard->card_id;
             $objTeamMember->owned_card_id = $firstCard->id;
         }
         $objTeamMember->save();
         switch ($intPosition) {
             case 1:
                 $objTeamBk->position_1_member_id = $objTeamMember->id;
                 break;
             case 2:
                 $objTeamBk->position_2_member_id = $objTeamMember->id;
                 break;
             case 3:
                 $objTeamBk->position_3_member_id = $objTeamMember->id;
                 break;
             case 4:
                 $objTeamBk->position_4_member_id = $objTeamMember->id;
                 break;
             case 5:
                 $objTeamBk->position_5_member_id = $objTeamMember->id;
                 break;
             case 6:
                 $objTeamBk->position_6_member_id = $objTeamMember->id;
                 break;
             default:
                 # code...
                 break;
         }
         // 20151103 追加
         $firstCard->team_id = $objTeam->id;
         $firstCard->save();
     }
     $objTeamBk->save();
     return Response::json($objTeamBk->toArray());
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $team = Team::find($id);
     $path = $team->logo_path;
     $name = $team->logo_name;
     $file = $path . $name;
     if (\File::isFile($file)) {
         \File::delete($file);
     }
     $team->delete();
     flash()->success('', 'Komanda ištrinta!');
     return Redirect::to('/dashboard/teams/');
 }
Beispiel #13
0
 /**
  * 玩家创建时初始化第一套队伍
  */
 public function firstTeam()
 {
     // Transaction
     DB::beginTransaction();
     try {
         $objTeam = new Team();
         $intPlayerId = $this->id;
         $objTeam->player_id = $intPlayerId;
         $objFirstCard = OwnedCard::where('player_id', $intPlayerId)->orderBy('id', 'ASC')->first();
         $objTeam->position_1_owned_card_id = $objFirstCard->id;
         $objTeam->total_cost = $objFirstCard->getCost();
         $objTeam->save();
         // TODO 是否需要
         $objTeamBk = Team::find($objTeam->id);
         // 20151012 TeamMember Table 初始化
         for ($intPosition = 1; $intPosition <= 6; $intPosition++) {
             $objTeamMember = new TeamMember();
             $objTeamMember->team_id = $objTeamBk->id;
             $objTeamMember->position = $intPosition;
             $objTeamMember->player_id = $objTeamBk->player_id;
             if ($intPosition == 1) {
                 $objTeamMember->card_id = $objFirstCard->card_id;
                 $objTeamMember->owned_card_id = $objFirstCard->id;
             }
             if (!$objTeamMember->save()) {
                 throw new Exception('Save Failed');
             }
             switch ($intPosition) {
                 case 1:
                     $objTeamBk->position_1_member_id = $objTeamMember->id;
                     break;
                 case 2:
                     $objTeamBk->position_2_member_id = $objTeamMember->id;
                     break;
                 case 3:
                     $objTeamBk->position_3_member_id = $objTeamMember->id;
                     break;
                 case 4:
                     $objTeamBk->position_4_member_id = $objTeamMember->id;
                     break;
                 case 5:
                     $objTeamBk->position_5_member_id = $objTeamMember->id;
                     break;
                 case 6:
                     $objTeamBk->position_6_member_id = $objTeamMember->id;
                     break;
             }
             // 更新玩家卡片的队伍信息
             $objFirstCard->team_id = $objTeam->id;
             if (!$objFirstCard->save()) {
                 throw new Exception('Save Failed');
             }
         }
         if (!$objTeamBk->save()) {
             throw new Exception('Save Failed');
         }
         DB::commit();
     } catch (Exception $e) {
         // TODO Dev Log
         DB::rollback();
     }
 }
 public function DelTeam($id, $id_team)
 {
     // Start Check Authorization
     /**
      * 1. FullAccess - 1
      * 2. HRD - 3
      * 3. Creator - 5
      * 4. Handler - 7
      */
     $invalid_auth = 1;
     $authRole = Auth::user()->UserRoles->role;
     if ($authRole == 7 or $authRole == 1 or $authRole == 3) {
         $invalid_auth = 0;
     }
     if ($invalid_auth == 1) {
         Alert::error('Anda tidak memilik akses ini')->persistent('close');
         return redirect('project/view/' . $id);
     }
     // End Check Authorization
     $db = Team::find($id_team);
     $db->status = 0;
     $db->save();
     $now = date('Y-m-d');
     foreach ($db->tl as $tl) {
         $db_tl = Teamleader::find($tl->id);
         $db_tl->status = 0;
         $db_tl->end = $now;
         $db_tl->save();
     }
     foreach ($db->store as $store) {
         $db_st = Store::find($store->id);
         $db_st->status = 0;
         $db_st->save();
         foreach ($store->members as $gm) {
             $db_gm = Member::find($gm->id);
             $db_gm->status = 0;
             $db_gm->end = $now;
             $db_gm->save();
             foreach ($gm->get_users as $gu) {
                 if ($gm->status == 1) {
                     $db_em = Employee::find($gu->id);
                     $db_em->status = 0;
                     $db_em->save();
                 }
             }
         }
     }
     Alert::success('Berhasil menonaktifkan !')->persistent("Close");
     return redirect('project/view/' . $id)->with('message', 'Stop Team Success!');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     $team = Team::find($id);
     $team->delete();
     Session::flash('message', 'Successfully deleted your team.');
     return Redirect::to('user/teams');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $deleteTeam = Team::find($id)->delete();
     if ($deleteTeam) {
         return ['id' => $id];
     } else {
         return 0;
     }
 }
Beispiel #17
0
 public function addTeam()
 {
     $lstTeams = Team::where("player_id", $this->_intPlayerId)->get()->toArray();
     $intTeamCount = count($lstTeams);
     // TODO Team数量限定
     $intNewTeamNo = $intTeamCount + 1;
     $objNewTeam = new Team();
     $objNewTeam->team_name = "Team" . $intNewTeamNo;
     $objNewTeam->team_no = $intNewTeamNo;
     $objNewTeam->player_id = $this->_intPlayerId;
     $objNewTeam->save();
     $objTeamBk = Team::find($objNewTeam->id);
     // 20151012 TeamMember Table 初始化
     for ($intPosition = 1; $intPosition <= 6; $intPosition++) {
         $objTeamMember = new TeamMember();
         $objTeamMember->team_id = $objTeamBk->id;
         $objTeamMember->position = $intPosition;
         $objTeamMember->player_id = $objTeamBk->player_id;
         $objTeamMember->save();
         switch ($intPosition) {
             case 1:
                 $objTeamBk->position_1_member_id = $objTeamMember->id;
                 break;
             case 2:
                 $objTeamBk->position_2_member_id = $objTeamMember->id;
                 break;
             case 3:
                 $objTeamBk->position_3_member_id = $objTeamMember->id;
                 break;
             case 4:
                 $objTeamBk->position_4_member_id = $objTeamMember->id;
                 break;
             case 5:
                 $objTeamBk->position_5_member_id = $objTeamMember->id;
                 break;
             case 6:
                 $objTeamBk->position_6_member_id = $objTeamMember->id;
                 break;
             default:
                 # code...
                 break;
         }
     }
     $objTeamBk->save();
 }
 public function addPerson($id)
 {
     $team = Team::find($id);
     if ($team === null) {
         return redirect('teams')->withError(trans('app.teamNotExists', ['id' => $id]));
     }
     $person_id = (int) Input::get('person');
     if (!$team->persons()->where('person_id', $person_id)->exists()) {
         $team->persons()->attach($person_id);
     }
     return redirect()->route('team.edit', $team->id);
 }
Beispiel #19
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $team = \App\Team::find($id)->members;
     return view('app.content.teamMembers', ['team' => $team]);
 }
 public function DelTeam($id, $id_team)
 {
     $db = Team::find($id_team);
     $db->status = 0;
     $db->save();
     $now = date('Y-m-d');
     foreach ($db->tl as $tl) {
         $db_tl = Teamleader::find($tl->id);
         $db_tl->status = 0;
         $db_tl->end = $now;
         $db_tl->save();
     }
     foreach ($db->store as $store) {
         $db_st = Store::find($store->id);
         $db_st->status = 0;
         $db_st->save();
         foreach ($store->members as $gm) {
             $db_gm = Member::find($gm->id);
             $db_gm->status = 0;
             $db_gm->end = $now;
             $db_gm->save();
             foreach ($gm->get_users as $gu) {
                 if ($gm->status == 1) {
                     $db_em = Employee::find($gu->id);
                     $db_em->status = 0;
                     $db_em->save();
                 }
             }
         }
     }
     Alert::success('Berhasil menonaktifkan !')->persistent("Close");
     return redirect('project/view/' . $id)->with('message', 'Stop Team Success!');
 }
Beispiel #21
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $team = Team::find($id);
     // is not creator
     // denied
     if (Gate::denies('update-team', $team)) {
         return redirect()->route('admin.team.index')->with('message', 'Access denied !');
     }
     $team->delete();
     $staff_team = StaffTeam::where('team_id', $id)->get();
     foreach ($staff_team as $key => $value) {
         StaffTeam::where(['team_id' => $id, 'staff_id' => $value->staff_id])->delete();
     }
     return redirect()->route('admin.team.index')->with('message', 'Delete success !');
 }
 public function delete($id)
 {
     $list = TeamDetail::where('team_id', $id)->get();
     foreach ($list as $key => $value) {
         $value->delete();
     }
     Team::find($id)->delete();
     return redirect()->route('admin.team.index')->with('success', 'successfully deleted');
 }
Beispiel #23
0
 /**
  * 开始一场战斗
  * @return mixed
  */
 public function start()
 {
     // TODO 各种Check
     // 各项参数取得
     $intPlayerId = Input::get('player_id', 0);
     $intDungeonId = Input::get('dungeon_id', 0);
     $strType = Input::get('type', 'normal');
     $now = Carbon::now();
     // 有没有进行中的战斗
     $objBattle = Battle::where('player_id', $intPlayerId)->where('dungeon_id', $intDungeonId)->where('end_datetime', '>', $now)->orderBy('id', 'DESC')->first();
     // 存在进行中的战斗
     if (!empty($objBattle)) {
         return Response::json($objBattle->toArray());
     }
     // 取得地下城信息
     $lstDungeonInfo = Dungeon::getInfo($intDungeonId);
     // 没有找到该当地下城
     if (empty($lstDungeonInfo)) {
         return 'Dungeon not exist';
     }
     // 取得地下城对象
     $objDungeon = $lstDungeonInfo['info'];
     // Team TODO
     $intTeamId = Input::get('team_id');
     $objTeam = Team::find($intTeamId);
     if (!$objTeam) {
         return 'NG TeamId';
     }
     // 队伍的PlayerId不一致的情况
     if ($objTeam->player_id != $intPlayerId) {
         return 'Wrong PlayerId For Team';
     }
     // 冒险做成
     $objBattle = new Battle();
     // 冒险情报的各种设定
     $objBattle->player_id = $intPlayerId;
     $objBattle->dungeon_id = $intDungeonId;
     $objBattle->floor = $objDungeon->floor;
     $objBattle->current_floor = 0;
     $objBattle->type = $strType;
     $objBattle->start_datetime = $now->toDateTimeString();
     $objBattle->end_datetime = $now->addMinutes($objDungeon->floor)->toDateTimeString();
     // 出战队伍信息保存在冒险信息中
     if ($objTeam->position_1_owned_card_id != 0) {
         $ownedCard1 = OwnedCard::find($objTeam->position_1_owned_card_id);
         $objBattle->position_1 = $ownedCard1->id;
     }
     if ($objTeam->position_2_owned_card_id != 0) {
         $ownedCard2 = OwnedCard::find($objTeam->position_2_owned_card_id);
         $objBattle->position_2 = $ownedCard2->id;
     }
     if ($objTeam->position_3_owned_card_id != 0) {
         $ownedCard3 = OwnedCard::find($objTeam->position_3_owned_card_id);
         $objBattle->position_3 = $ownedCard3->id;
     }
     if ($objTeam->position_4_owned_card_id != 0) {
         $ownedCard4 = OwnedCard::find($objTeam->position_4_owned_card_id);
         $objBattle->position_4 = $ownedCard4->id;
     }
     if ($objTeam->position_5_owned_card_id != 0) {
         $ownedCard5 = OwnedCard::find($objTeam->position_5_owned_card_id);
         $objBattle->position_5 = $ownedCard5->id;
     }
     if ($objTeam->position_6_owned_card_id != 0) {
         $ownedCard6 = OwnedCard::find($objTeam->position_6_owned_card_id);
         $objBattle->position_6 = $ownedCard6->id;
     }
     if ($objBattle->save()) {
         return Response::json($objBattle->toArray());
     }
 }
 public function show($id)
 {
     return view('team.detail', ['team' => Team::find($id)]);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['photo' => 'image|max:2000', 'name' => 'required|min:5', 'position' => 'required', 'description' => 'required|min:30', 'description2' => 'required_with:description3']);
     $member = [];
     if ($request->input('photo')) {
         $photo = Input::file('photo');
         if ($photo->isValid()) {
             $ext = $photo->getClientOriginalExtension();
             $destination = 'images';
             $name = explode(' ', $request->input('name'));
             $name = strtolower($name[0]);
             $filename = $name . '.' . $ext;
             $member['photo'] = $filename;
             $photo->move($destination, $filename);
         }
     }
     $member['name'] = strtolower($request->input('name'));
     $member['position'] = strtolower($request->input('position'));
     $member['description'] = $request->input('description');
     $member['description2'] = trim($request->input('description2')) != "" ? trim($request->input('description2')) : null;
     $member['description3'] = trim($request->input('description3')) != "" ? trim($request->input('description3')) : null;
     Team::find($id)->update($member);
     return redirect('admin/team');
 }
 /**
  * Save a match to the provided event
  *
  * @return redirect
  **/
 public function saveMatch(CreateMatchRequest $request, Event $event)
 {
     $match = new Match();
     $match->match_type_id = MatchType::where('identifier', $event->type)->first()->id;
     $match->event_id = $event->id;
     $match->save();
     // if there is a team selected then we're going with teams.
     if ($request->teamBlack) {
         $match->teams()->save(Team::find($request->teamBlack));
         $match->teams()->save(Team::find($request->teamYellow));
     } elseif ($request->playersBlack) {
         $teamBlack = new Team();
         $teamBlack->save();
         $teamYellow = new Team();
         $teamYellow->save();
         foreach ($request->playersBlack as $key => $playerId) {
             $teamBlack->players()->save(Player::find($playerId));
             $teamYellow->players()->save(Player::find($request->playersYellow[$key]));
         }
         $match->teams()->save($teamBlack);
         $match->teams()->save($teamYellow);
     }
     return redirect()->route('dashboard.events.single', $event->id)->with('app-success', 'Match created successfully.');
 }
Beispiel #27
0
 public function deleteTeam($id)
 {
     $team = Team::find($id);
     $integrantes = $team->integrantes;
     foreach ($integrantes as $user) {
         $user->id_team = 0;
         $user->save();
     }
     $team->delete();
     return redirect('/admin/team');
 }
Beispiel #28
0
 public function RunUpdateTeam($id)
 {
     $team = Team::find($id);
     Artisan::call('FFTT:Team', ['type' => $team->type, 'libequipe' => $team->libequipe, 'libdivision' => $team->libdivision, 'liendivision' => $team->liendivision]);
     return redirect()->route('AdmBatchsTeams');
 }