/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next, $param) { switch ($param) { case "url": if (Stage::where('url', $request->url)->count() > 0) { return $next($request); } break; case "id": if (Stage::find($request->id)) { return $next($request); } break; } return redirect()->route('stages.index', ['course_url' => $request->course_url])->withErrors(['message' => 'Se está intentando editar una etapa inexistente']); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(StageRequest $request, $course_url, $id) { $name = $request->name; $url = UrlSanitizer::sanitize($name); $request["url"] = $url; $stage = Stage::find($id); $stage->update($request->all()); return redirect()->route('stages.index', ['course_url' => $course_url]); }
public function getInfoCombat(Request $request) { $da = $d = CombatRound::where('rb_combat_round.group_id', '=', $request->group_id)->join('rb_group_stage as r_g', 'r_g.round_id', '=', 'rb_combat_round.versus_one')->join('rb_group_stage as r_g2', 'r_g2.round_id', '=', 'rb_combat_round.versus_two')->join('rb_rounds as r_b', 'r_b.id', '=', 'r_g.round_id')->join('rb_rounds as r_b2', 'r_b2.id', '=', 'r_g2.round_id')->join('rb_team as r_t', 'r_t.id', '=', 'r_b.team_id')->join('rb_team as r_t2', 'r_t2.id', '=', 'r_b2.team_id')->join('rb_groups as r_gr', 'r_gr.id', '=', 'r_g.group_id')->join('rb_groups as r_gr2', 'r_gr2.id', '=', 'r_g2.group_id')->select('r_g.id as id_rg', 'r_g.group_id as group_id_rg', 'r_g2.id as id_rg2', 'r_g2.group_id as group_id_rg2', 'r_b.team_id as r_b_team_id', 'r_b2.team_id as r_b2_team_id', 'r_gr.name as r_gr_name', 'r_gr2.name as r_gr2_name', 'r_t.name as r_t_name', 'r_t2.name as r_t2_name', 'rb_combat_round.*')->orderBy('rb_combat_round.schedule_start', 'asc')->get()->toArray(); $stage = Stage::find($da[0]['stage_id']); return ['data_info' => $da, 'name' => $stage->name]; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Request $request) { //dd($request->all()); $d = Stage::find($request->id); $d->delete(); return response()->json(['success' => true]); }
/** * Display a list of all of the user's task. * * @param Request $request * @return Response */ public function index(Request $request) { //get basic objects $user = User::find($request->user()->id); $categories = Category::where('is_note', '=', 0)->orderBy('seq')->get(); $priorities = Priority::All(['id', 'name']); $stages = Stage::All(['id', 'name']); //handle stages filter if ($request->stage_id) { if ($request->stage_id > 0) { $request->session()->put('stage_id', $request->stage_id); $request->session()->put('stage', Stage::find($request->stage_id)->name); } else { $request->session()->put('stage_id', False); $request->session()->put('stage', "All Stages"); } } $ses_stage_id = $request->session()->get('stage_id'); //handle categories filter if ($request->category_id) { if ($request->category_id > 0) { $request->session()->put('category_id', $request->category_id); $request->session()->put('category', Category::find($request->category_id)->name); } else { $request->session()->put('category_id', False); $request->session()->put('category', "All Categories"); } } $ses_category_id = $request->session()->get('category_id'); //base query $tasks = DB::table('tasks')->leftjoin('categories', 'tasks.category_id', '=', 'categories.id')->join('priorities', 'tasks.priority_id', '=', 'priorities.id')->join('stages', 'tasks.stage_id', '=', 'stages.id')->select('tasks.name', 'tasks.deadline', 'tasks.id', 'tasks.created_at', 'tasks.updated_at', 'categories.name as cname', 'categories.css_class', 'priorities.name as pname', 'stages.name as sname')->where('user_id', '=', $request->user()->id); //handle stages if ($ses_stage_id) { $tasks->where('stage_id', '=', $ses_stage_id); } //handle categories if ($ses_category_id) { $tasks->where('category_id', '=', $ses_category_id); } //handle search if ($request->btn_search == "s") { if ($request->search) { $request->session()->put('search', $request->search); } else { $request->session()->forget('search'); } } $search = $request->session()->get('search'); if (strlen($search) > 0) { $tasks->where(function ($query) use($search) { $query->where('tasks.name', 'like', "%" . $search . "%")->orWhere('tasks.description', 'like', "%" . $search . "%"); }); } //handle filters if ($request->filter_deadline == 1) { $request->session()->put('filter_deadline', 1); } elseif ($request->filter_deadline == -1) { $request->session()->put('filter_deadline', 0); } $filter_deadline = $request->session()->get('filter_deadline'); if ($filter_deadline == 1) { $tasks->where('deadline', '!=', '0000-00-00')->where('deadline', '<=', date('Y-m-d', time())); } //handle sort order if ($request->order) { $request->session()->put('order', $request->order); } $order = $request->session()->get('order'); if (!$order) { $order = 'priority_id'; } //handle sort direction if ($request->dir) { $request->session()->put('dir', $request->dir); } $dir = $request->session()->get('dir'); if (!$dir) { $dir = 'ASC'; } //handle pagination -> we don't want to lose the page if ($request->page) { $request->session()->put('page', $request->page); } $page = $request->session()->get('page'); if ($request->n) { $request->session()->put('pagination_number', $request->n); } elseif ($request->session()->get('pagination_number') < 1) { $request->session()->put('pagination_number', 100); } $pagination_number = $request->session()->get('pagination_number'); $tasks = $tasks->orderBy('tasks.' . $order, $dir)->orderBy('deadline', 'ASC')->orderBy('tasks.name', 'ASC')->paginate($pagination_number); return view('tasks.index', ['categories' => $categories, 'priorities' => $priorities, 'stages' => $stages, 'tasks' => $tasks, 'order' => $order, 'dir' => $dir, 'stage' => $request->session()->get('stage'), 'category' => $request->session()->get('category'), 'search' => $search, 'page' => $page, 'filter_deadline' => $filter_deadline]); }