コード例 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $jobs = Job::with('creator')->orderBy('required_date')->paginate(4);
     if (Input::has('search')) {
         $search = Input::get('search');
         $jobs = Job::where('description', 'LIKE', '%' . $search . '%')->paginate(50);
     }
     $data = array('jobs' => $jobs);
     return View::make('temp_jobs.index')->with($data);
 }
コード例 #2
0
 public function search()
 {
     if (Auth::check()) {
         //do not show jobs that have already been applied to
         //to show active jobs that helper has been selected for
         $activeJobIds = DB::table('jobs')->join('helpers_jobs_mapping', function ($join) {
             $join->on('jobs.id', '=', 'helpers_jobs_mapping.job_id')->where('helpers_jobs_mapping.is_accepted', '=', 1);
         })->lists('id');
         $activeJobs = [];
         if (!empty($activeJobIds)) {
             $activeJobs = Job::whereIn('id', $activeJobIds)->get();
         }
         $appliedQuery = Auth::user()->appliedJobs();
         if (!empty($activeJobIds)) {
             $appliedQuery->whereNotIn('id', $activeJobIds);
         }
         $appliedJobs = $appliedQuery->get();
         //$jobsIds will hold all the ids in the jobs table
         $appliedJobIds = array();
         //search all jobs for current job id
         foreach (Auth::user()->appliedJobs as $job) {
             $appliedJobIds[] = $job->id;
         }
         $jobQuery = Job::with('creator');
         if (count($activeJobIds) > 0) {
             $jobQuery->whereNotIn('id', $activeJobIds);
         }
         if (count($appliedJobIds) > 0) {
             $jobQuery->whereNotIn('id', $appliedJobIds);
         }
         //show all jobs if user has not applied to any
         $jobs = $jobQuery->orderBy('required_date')->paginate(5);
         $data = array('jobs' => $jobs, 'activeJobs' => $activeJobs, 'appliedJobs' => $appliedJobs);
     } else {
         $jobs = Job::with('creator')->orderBy('required_date')->paginate(5);
     }
     if (Input::has('filter')) {
         $filter = Input::get('filter');
         $jobs = Job::where('category', $filter)->paginate(50);
     }
     if (Input::has('search')) {
         $search = Input::get('search');
         $jobs = Job::where('description', 'LIKE', '%' . $search . '%')->paginate(5);
     }
     $data = array('jobs' => $jobs);
     return View::make('pages.search')->with($data);
 }
コード例 #3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $review = Job::with('review')->find($id);
     return View::make('temp_reviews.create-edit')->with('review', $review);
 }
コード例 #4
0
 public function dashboard_helper($id)
 {
     //to show active jobs that helper has been selected for
     $activeJobIds = DB::table('jobs')->join('helpers_jobs_mapping', function ($join) {
         $join->on('jobs.id', '=', 'helpers_jobs_mapping.job_id')->where('helpers_jobs_mapping.is_accepted', '=', 1);
     })->lists('id');
     $activeJobs = [];
     if (!empty($activeJobIds)) {
         $activeJobs = Job::whereIn('id', $activeJobIds)->get();
     }
     $appliedQuery = Auth::user()->appliedJobs();
     if (!empty($activeJobIds)) {
         $appliedQuery->whereNotIn('id', $activeJobIds);
     }
     $appliedJobs = $appliedQuery->get();
     //$jobsIds will hold all the ids in the jobs table
     $appliedJobIds = array();
     //search all jobs for current job id
     foreach (Auth::user()->appliedJobs as $job) {
         $appliedJobIds[] = $job->id;
     }
     //do not show jobs that have already been applied to
     $jobQuery = Job::with('creator');
     if (count($activeJobIds) > 0) {
         $jobQuery->whereNotIn('id', $activeJobIds);
     }
     if (count($appliedJobIds) > 0) {
         $jobQuery->whereNotIn('id', $appliedJobIds);
     }
     //show all jobs if user has not applied to any
     $jobs = $jobQuery->orderBy('created_at', 'desc')->paginate(4);
     $data = array('jobs' => $jobs, 'activeJobs' => $activeJobs, 'appliedJobs' => $appliedJobs);
     return View::make('users.show_account')->with($data);
 }