예제 #1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $job_id = $id;
     $job_info = Job::find($job_id);
     $job_category_info = JobCategory::where('job_id', '=', $job_id)->get();
     $category_array = array();
     foreach ($job_category_info as $a_job_category) {
         $a_category_id = $a_job_category->category_id;
         $a_category_value = Category::find($a_category_id)->kategori;
         $category_array[count($category_array)] = $a_category_value;
     }
     $data['job_info'] = $job_info;
     $data['category_array'] = $category_array;
     // find out whether the logged-in user have already request this job (as a seeker)
     // if the owner of this job is the logged-in user, then don't show the request button
     $show_request_button = true;
     $this_is_the_owner = false;
     if (Auth::user() != null) {
         $logged_user_id = Auth::user()->id;
         if ($job_info->freelancer_info_id == $logged_user_id) {
             // if the owner of this job is the logged-in user
             $show_request_button = false;
             $this_is_the_owner = true;
         } else {
             // if logged-in user already request this job (as a seeker)
             if (JobRequest::find($job_id, $logged_user_id) != null) {
                 $show_request_button = false;
             }
         }
     } else {
         //if guest (not logged-in user)
     }
     return View::make('job.show')->with('data', $data)->with('jobs', $job_info)->with('job_id', $id)->with('show_request_button', $show_request_button)->with('this_is_the_owner', $this_is_the_owner);
 }
예제 #2
0
 /**
  * Accept job from seeker
  *
  * @return Response
  */
 public function acceptJob()
 {
     $job_id = Input::get('job_id');
     $seeker_id = Input::get('seeker_id');
     //accept job, create accepted_job
     $accepted_job = new AcceptedJob();
     $accepted_job->job_id = $job_id;
     $accepted_job->seeker_id = $seeker_id;
     $accepted_job->save();
     //delete request
     $job_request = JobRequest::find($job_id, $seeker_id);
     //$job_request->delete();
     $query = "DELETE FROM job_request ";
     $query = $query . "WHERE job_id = " . $job_id . " and seeker_id = " . $seeker_id;
     DB::select(DB::raw($query));
     // add notification to the freelacer
     $freelancer_id = User::find(FreelancerInfo::find(Job::find($job_id)->freelancer_info_id)->user_info_id)->id;
     $freelancer_name = User::find($freelancer_id)->name;
     $job_name = Job::find($job_id)->judul;
     $notification = new Notification();
     $notification->user_id = $seeker_id;
     $notification->notif = "Tawaran job " . $job_name . " telah diterima oleh freelancer " . $freelancer_name;
     $notification->type = 2;
     $notification->save();
     return Redirect::to('show-job-request/');
 }