/** * get users supported issues * * @return json * @author **/ public function getSupported($order = 'latest') { $hood = null; if (!Auth::check()) { return redirect('/')->with('error', 'Giriş yapıp tekrar deneyebilirsiniz.'); } $issue_ids = DB::table('issue_supporters')->where('user_id', Auth::user()->id)->lists('issue_id'); if (empty($issue_ids)) { return redirect('/')->with('error', 'Henüz hiç bir fikri desteklememişsiniz.'); } $o = 'id'; if ($order == 'popular') { $o = 'supporter_count'; } $issues = Issue::with('user', 'tags', 'images')->whereIn('id', $issue_ids); $o1 = 'id'; $o2 = 'desc'; $order = 'latest'; if (Request::has('sort')) { $sort = Request::get('sort'); if ($sort == 'popular') { $o1 = 'supporter_count'; $order = 'popular'; } } $issues->orderBy($o1, $o2); if (Request::has('map') and (int) Request::get('map') === 1) { $data = $issues->paginate(20); return $this->displayMapData($data); } $issues = $issues->paginate(20); $response = []; if ($issues !== null) { $response = $issues->toArray(); } if ($this->isApi) { return response()->api(200, 'Issues starting with: ' . $start, $response); } view()->share('pageTitle', 'Fikir Listesi - '); session(['last_page' => Request::path()]); return response()->app(200, 'issues.supported', ['issues' => $issues, 'order' => $order, 'hood' => $hood]); }