Пример #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request, ApiRepository $apirepo)
 {
     if (!$request->all() == null) {
         //so you can search like this http://localhost/ewa2015/public/candidate?page=1&gender=F&party=1&blahblah=foobar
         $candidateList = $apirepo->getCandidateListBySearch($request);
     } else {
         //if request have no parameter here u go with normal pagination list
         $candidateList = $apirepo->getCandidateList();
     }
     if ($request->ajax()) {
         return json_encode($candidateList);
     }
     return view('candidate.all', compact('candidateList'));
 }
Пример #2
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request, ApiRepository $apirepo)
 {
     if (!$request->all() == null) {
         //so you can search like this http://localhost/ewa2015/public/candidate?page=1&gender=F&party=1&blahblah=foobar
         $candidateList = $apirepo->getCandidateListBySearch($request);
     } else {
         //if request have no parameter here u go with normal pagination list
         $candidateList = $apirepo->getCandidateList();
     }
     if ($request->ajax()) {
         return json_encode($candidateList);
     }
     $meta = $candidateList->meta;
     $data = [];
     foreach ($candidateList->data as $key => $value) {
         $value->like = $this->getLikeCountForCandidate($value->id);
         $data[] = $value;
     }
     $result['data'] = $data;
     $result['meta'] = $meta;
     $candidateList = (object) $result;
     return view('candidate.all', compact('candidateList'));
 }