/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(GamesRequest $request) { $games = Product::join('games as g', 'g.product_id', '=', 'id'); $games = $games->where('type', 'GAME'); $title = 'Game'; $heading = 'Game'; // platform if (!empty($request->platform)) { $games = $games->where('g.platform_id', Platform::where('name', $request->platform)->first()->id); $heading = $request->platform . ' ' . $heading + 's'; } // query if (!empty($request->q)) { $games = $games->where('name', 'LIKE', '%' . $request->q . '%'); } // sort if (!empty($request->sort)) { $games = $games->orderBy($request->sort, $request->order); } else { $games = $games->orderBy('g.updated_at', 'desc'); } // flash input $request->flash(); return view('games.index')->with('title', $title)->with('heading', $heading)->with('games', $games->paginate(env('PAGINATE'))); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { Platform::find($id)->update($request->all()); // flash message session()->flash('flash_message', 'Platform updated successfully.'); return redirect()->route('platforms.index'); }
public function settings() { $platforms = \App\Platform::all(); $countries = \App\Country::orderBy('name', 'asc')->get(); return view('user/settings', compact('platforms', 'countries')); }
public function deletePlatform(Request $request) { if (!$request->platform) { return Response::json(["status" => "ERROR", "response" => "Invalid parameters."], 400); } $user = User::where('user_token', $request->token)->first(); if (!$user) { return Response::json(["status" => "ERROR", "response" => "User doesn't exist"], 400); } $platform = Platform::where('recruiter_id', $user->id)->where('platform', $request->platform)->delete(); // Reply return Response::json(["status" => "OK", "response" => $platform], 200); }