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 jobAlerts() { if (!is_null(Session::get('candidate'))) { $candidate = Candidate::find(Session::get('candidate')->id); $sectors = JobAlerts::getJobSectors(); $job_types = JobAlerts::getJobTypes(); $locations = JobAlerts::getJobLocations(); // Check if there is an alert already $jobAlert = JobAlerts::where('candidate_id', $candidate->id)->first(); if (!is_null($jobAlert)) { $alert = $jobAlert; // Now we have an alert let check for relevant jobs $jobs = DB::select("EXEC spJobSearch_Select @JobTitle = '', @LocationIDs = '{$alert->location_id}', @SectorIDs = '{$alert->sector_id}', @EmploymentTypeIDs = '{$alert->job_type}'"); } else { $alert = []; $jobs = []; } $viewSectors = $viewlocations = []; foreach ($sectors as $sector) { $viewSectors[$sector->SectorId] = $sector->SectorName; } foreach ($locations as $location) { $viewlocations[$location->LocationId] = $location->Description; } return View::make('candidate.jobalerts', ['candidate' => $candidate, 'sectors' => $viewSectors, 'job_types' => $job_types, 'locations' => $viewlocations, 'alert' => $alert, 'jobs' => $jobs]); } else { return Redirect::to('become-a-candidate')->with('info', 'Please login / register to view this page'); } }