Esempio n. 1
0
 /**
  * Create a Job
  * @return \Illuminate\Http\JsonResponse
  */
 public function create()
 {
     Log::info(\Input::all());
     $inputdata = \Input::all();
     $success = false;
     $inputdata["mandate_start"] = strtotime($inputdata["mandate_start"]);
     $inputdata["mandate_end"] = strtotime($inputdata["mandate_end"]);
     $inputdata["date_of_entry"] = strtotime($inputdata["date_of_entry"]);
     if ($this->validator->validate(\Input::all())) {
         $job = Job::create($inputdata);
         if (\Input::has('skills')) {
             $skills = [];
             foreach (\Input::get('skills') as $skill) {
                 $skills[$skill['skill_id']] = ['description' => isset($skill['description']) ? $skill['description'] : '', 'level' => isset($skill['level']) ? $skill['level'] : 0];
             }
             $job->skills()->attach($skills);
         }
         if (\Input::get('agent_id')) {
             $agent = Agent::find(\Input::get('agent_id'));
             // $job->agents()->attach($agent->user_id);
             $job->agent_id = $agent->user_id;
         }
     }
     $success = $job == true;
     return \Response::json(['success' => $success]);
 }
Esempio n. 2
0
 public function run()
 {
     $faker = Faker::create();
     $agencies = Agency::lists('id');
     foreach (range(1, 50) as $index) {
         $job = Job::create(['agency_id' => $faker->randomElement($agencies), 'title' => $faker->sentence(), 'slug' => $faker->unique()->slug, 'client_id' => $faker->numberBetween(1, 10), 'agent_id' => $faker->numberBetween(21, 40), 'hr_id' => $faker->numberBetween(1, 10), 'is_published' => true, 'about' => $faker->paragraph(), 'salary_range_to' => $faker->numberBetween(4000, 5000), 'salary_range_from' => $faker->numberBetween(1000, 2000), 'mandate_start' => time(), 'mandate_end' => time() + 86400, 'age_range_to' => 18, 'age_range_from' => 35, 'date_of_entry' => $faker->numberBetween(time() - 100000, time() + 100000), 'contract_type_id' => $faker->numberBetween(1, 3)]);
         foreach (range(1, 3) as $index) {
             $job->skills()->attach([$faker->numberBetween(1, 6000) => ['description' => $faker->sentence(), 'level' => $faker->numberBetween(1, 100)]]);
         }
     }
 }