コード例 #1
0
 public function getPublicProfilePage($id, $slug)
 {
     $_hash = new Hash();
     $_hash = $_hash->getHasher();
     $company = \Company::findCompanyById($_hash->decode($id));
     if (!$company) {
         return abort(404);
     }
     return view('front.company.publicProfile')->with('model', $company);
 }
コード例 #2
0
 public function postEditJob()
 {
     $data = \Input::get('data');
     $_hash = new Hash();
     $_hash = $_hash->getHasher();
     if (!($job = \Job::findJobById(trim(\Input::get('job'))))) {
         return \Response::json(['type' => 'danger', 'message' => 'Job not found.']);
     }
     if (!($company = \Company::findCompanyById($_hash->decode($data['company'])))) {
         return \Response::json(['type' => 'danger', 'message' => 'Company not found.']);
     }
     if (!($agency = \Agency::getAgency())) {
         return \Response::json(['type' => 'danger', 'message' => 'Not an agency account.']);
     }
     if ($data['job_post_duration'] !== '0') {
         if (!$agency->is_vip) {
             $value = ['1' => -1, '2' => -3];
             $checkValue = abs($value[$data['job_post_duration']]);
             if ($agency->credit < $checkValue) {
                 return \Response::json(['type' => 'warning', 'message' => 'You have ' . $agency->credit . ' credit. You need at least ' . $checkValue . ' credit(s) to post this job.']);
             }
         }
     }
     $status = $company->agencies()->wherePivot('company_id', $company->id)->wherePivot('status', 'accept')->first();
     if (!$status) {
         return \Response::json(['type' => 'danger', 'message' => 'You do not have permission from this company to post a job']);
     }
     $data['agency_id'] = $agency->id;
     $data['company_id'] = $company->id;
     if ($data['job_apply_type'] === 'job_apply_by_email') {
         if ($data['job_apply_application_email'] === '' && $data['job_apply_direct_email'] === '') {
             return \Response::json(['type' => 'warning', 'message' => 'Job application by email is chosen, please input at least one email.']);
         }
         $data['job_apply_details'] = json_encode(['type' => 'email', 'application_email' => $data['job_apply_application_email'], 'direct_email' => $data['job_apply_direct_email']]);
     } elseif ($data['job_apply_type'] === 'job_apply_by_url') {
         if ($data['job_apply_url'] === '') {
             return \Response::json(['type' => 'warning', 'message' => 'Job application by url is chosen, please input the application url.']);
         }
         $data['job_apply_details'] = json_encode(['type' => 'url', 'url' => $data['job_apply_url']]);
     }
     try {
         $job = \Job::updateJob($job, $data);
         if (!$agency->is_vip && $data['job_post_duration'] !== '0') {
             \Agency::updateCredit($agency, $value[$data['job_post_duration']]);
         }
         return \Response::json(['type' => 'success', 'message' => 'Job updated successfully.']);
     } catch (\Exception $e) {
         return \Response::json(['type' => 'danger', 'message' => env('APP_DEBUG') ? $e->getMessage() : 'Error, please contact webmaster.']);
     }
 }
コード例 #3
0
 public function getJobListingFrame($id, $type)
 {
     $_hash = new Hash();
     $_hash = $_hash->getHasher();
     switch ($type) {
         case 'company':
             if (!($company = \Company::findCompanyById($_hash->decode($id)))) {
                 return view('frame.job')->with('flashMessage', ['class' => 'danger', 'message' => 'Company not found.']);
             }
             if (!($jobs = $company->jobs()->get())) {
                 return view('frame.job')->with('flashMessage', ['class' => 'danger', 'message' => 'Jobs not found.']);
             }
             return view('frame.job')->with('jobs', $jobs);
             break;
         case 'agency':
             if (!($agency = \Agency::findAgencyById($_hash->decode($id)))) {
                 return view('frame.job')->with('flashMessage', ['class' => 'danger', 'message' => 'Agency not found.']);
             }
             if (!($jobs = $agency->jobs()->get())) {
                 return view('frame.job')->with('flashMessage', ['class' => 'danger', 'message' => 'Jobs not found.']);
             }
             return view('frame.job')->with('jobs', $jobs);
             break;
         default:
             return view('frame.job')->with('flashMessage', ['class' => 'danger', 'message' => 'Type is incorrectly defined.']);
             break;
     }
 }