/** * 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'))); }
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); }