public function deleteJobCategory()
 {
     $id = Input::get('id');
     JobCategory::where('id', '=', $id)->delete();
 }
Esempio n. 2
0
 /**
  * Show the form for creating a new job
  *
  * @return Response
  */
 public function anyCreate($id = 0)
 {
     $user = Sentry::getUser();
     $jobCategories = JobCategory::where('active', '=', 1)->orderBy('name')->lists("name", "id");
     $jobSubCats = JobSubCategory::all();
     $jobSubCategories = array();
     foreach ($jobSubCats as $sub) {
         if (!isset($jobSubCategories[$sub->category_id])) {
             $jobSubCategories[$sub->category_id] = array();
         }
         $jobSubCategories[$sub->category_id][$sub->id] = $sub->name;
     }
     $certifications = Certification::lists("display_value_employer", 'id');
     $states = Address::ListStates();
     $addresses = Address::Where("user_id", "=", $user->id)->WhereIn("address_type_id", array(AddressType::$HOME, AddressType::$BUSINESS))->orderBy('created_at', 'desc')->get();
     $homeAddressId = 0;
     $businessAddressId = 0;
     $homeAddress = null;
     $businessAddress = null;
     foreach ($addresses as $address) {
         switch ($address->address_type_id) {
             case AddressType::$HOME:
                 if ($homeAddressId <= 0) {
                     $homeAddress = $address;
                     $homeAddressId = $address->id;
                 }
                 break;
             case AddressType::$BUSINESS:
                 if ($businessAddressId <= 0) {
                     $businessAddress = $address;
                     $businessAddressId = $address->id;
                 }
                 break;
         }
     }
     $repost = false;
     $pastJobs = JobApplicant::where('jobs.user_id', '=', $user->id)->join('jobs', 'jobs.id', '=', 'job_applicants.job_id')->where('job_applicants.job_applicant_status_id', '=', JobApplicantStatus::$AWARDED)->select('job_applicants.*')->distinct()->get();
     $pastJobs->load('User');
     $favorites = array();
     foreach ($pastJobs as $u) {
         if ($u->user != null) {
             $favorites[$u->user_id] = $u->user->first_name . " " . $u->user->last_name;
         }
     }
     if (intval($id) > 0) {
         $job = Job::find($id);
         if ($job != null) {
             $job->start_date = "";
             $repost = true;
             if ($job->address_id == $businessAddressId || $job->address_id == $homeAddressId) {
                 $job->address1 = "";
                 $job->address2 = "";
                 $job->city = "";
                 $job->state = "";
                 $job->zipcode = "";
             }
         }
     } else {
         $job = new Job();
     }
     return View::make('jobs.create', compact("homeAddress", "businessAddress", 'favorites', 'repost', 'job', "jobCategories", 'jobSubCategories', 'states', 'certifications', 'homeAddressId', 'businessAddressId'));
 }