public function getJobs() { $displayTitle = "Jobs"; //.$sectorId; $sectors = DB::select("EXEC spSectors_Select"); dd($sectors); $job_types = JobAlerts::getJobTypes(); $locations = DB::select("EXEC spLocations_Select"); $numOfJobs = 5; $pageNumber = Input::get('page') ?: 1; $jobs = []; $paginator = Paginator::make($jobs, count(DB::select("EXEC spJobSearch_Select @JobTitle = '', @SectorIDs = '{$sectors_get}', @LocationIDs = '{$location_get}', @EmploymentTypeIDs = '{$type_get}'")), $numOfJobs); $jobs = DB::select("EXEC spJobSearchPaged_Select @JobTitle = ?, @SectorIDs = '{$sectors}', @LocationIDs = '{$location_get}', @EmploymentTypeIDs = '{$type_get}', @RowsPerPage = {$numOfJobs}, @PageNumber = {$pageNumber}", explode('+', $keywords)); $recommended = self::getRecommendedJobs(); return View::make('jobs')->with('jobs', $jobs)->with('reccommended', $reccommended)->with('sectors', $sectors)->with('job_types', $job_types)->with('locations', $locations)->with('displayTitle', $displayTitle)->with('paginator', $paginator); }
public function fire() { $sectors = JobAlerts::getJobSectors(); $jobTypes = JobAlerts::getJobTypes(); $locations = JobAlerts::getJobLocations(); // loop through all candidates Candidates::get()->each(function ($candidate) use($sectors, $jobTypes, $locations) { $candidate->jobAlerts->each(function ($jobAlert) use($sectors, $jobTypes, $locations) { // select all jobs, query derived from controller $jobs = DB::select("\n\t\t\t\t\tEXEC spJobSearch_Select \n\t\t\t\t\t@JobTitle = '', \n\t\t\t\t\t@LocationIDs = '{$jobAlert->location_id}', \n\t\t\t\t\t@SectorIDs = '{$jobAlert->sector_id}', \n\t\t\t\t\t@EmploymentTypeIDs = '{$jobAlert->job_type}'"); // dispatch mail Mail::send('candidate.jobalerts', ['sectors' => $sectors, 'job_types' => $jobTypes, 'locations' => $locations, 'alert' => $jobAlert, 'jobs' => $jobs], function ($message) use($candidate) { $message->to($candidate->email, $candidate->name)->subject('Job Alerts from KDC'); }); }); }); }
public function jobAlertsPost() { // dd(Input::all()); if (!is_null(Session::get('candidate'))) { $candidate = Candidate::find(Session::get('candidate')->id); $input = Input::all(); // Check if there is an alert already $jobAlert = JobAlerts::where('candidate_id', $candidate->id)->first(); if (is_null($jobAlert)) { $alert = new JobAlerts(); } else { $alert = $jobAlert; } if (isset($input['active'])) { $active = 1; } else { $active = 0; } $alert->candidate_id = $candidate->id; $alert->job_type = $input['job_type_id']; $alert->sector_id = $input['sector_id']; $alert->location_id = $input['location_id']; $alert->salary_expectations = $input['salary']; $alert->keywords = $input['job_keywords']; $alert->skill_keywords = $input['skill_keywords']; $alert->active = $active; $alert->save(); return Redirect::back()->withInfo('Your alert settings have been saved'); } else { return Redirect::to('become-a-candidate')->with('info', 'Please login / register to view this page'); } }