Ejemplo n.º 1
0
 public function run()
 {
     $faker = \Faker\Factory::create();
     //Applicant::truncate();
     foreach (range(1, 26) as $index) {
         $applicant = new Applicant(array('fname' => $faker->firstName(), 'mname' => $faker->lastName(), 'lname' => $faker->lastName(), 'age' => $faker->numberBetween(18, 35), 'birthdate' => $faker->date('Y-m-d'), 'date_applied' => '2015-9-20', 'address' => $faker->address(), 'contact_num' => "0910" . $faker->shuffle("9067831"), 'email_add' => $faker->email(), 'status' => 2, 'position_id' => mt_rand(1, 10)));
         $applicant->save();
         foreach (range(1, mt_rand(3, 4)) as $n) {
             if ($n == 1) {
                 $level = 'Elementary';
             } else {
                 if ($n == 2) {
                     $level = "Secondary";
                 } else {
                     if ($n == 3) {
                         $level = "Tertiary";
                     } else {
                         $level = "Postgrad";
                     }
                 }
             }
             $educxp = new EducXp(array('level' => $level, 'school_name' => $faker->text(20), 'school_address' => $faker->streetName() . ", " . $faker->city(), 'date_grad' => $faker->year()));
             $applicant->educXps()->save($educxp);
         }
         foreach (range(1, mt_rand(1, 5)) as $n) {
             $workxp = new WorkXp(array('position' => $faker->text(20), 'company_name' => $faker->company(), 'task_description' => $faker->paragraph(4), 'date_started' => $faker->month() . '-' . $faker->year(), 'date_ended' => $faker->month() . '-' . $faker->year()));
             $applicant->workXps()->save($workxp);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  ApplicationFormRequest  $request
  * @return Response
  */
 public function store(ApplicationFormRequest $request)
 {
     if (!session()->has('newCode')) {
         return \Redirect::route('form.index')->with('alertMessage', 'The code is expired!');
     }
     //save applicant main profile
     $applicant = new Applicant(array('fname' => $request->get('fname'), 'mname' => $request->get('mname'), 'lname' => $request->get('lname'), 'age' => $request->get('age'), 'birthdate' => $request->get('birthdate'), 'date_applied' => $request->get('date_applied'), 'address' => $request->get('address'), 'contact_num' => $request->get('contact_num'), 'email_add' => $request->get('email_add'), 'position_id' => $request->get('position_id'), 'status' => 0));
     $applicant->save();
     //get educational attinment(s)
     $level = Input::get('level');
     $schoolname = Input::get('school_name');
     $yeargrad = Input::get('year_grad');
     $schooladd = Input::get('school_address');
     //add each attainment to the current profile
     foreach ($schoolname as $key => $n) {
         $educxp = new EducXp(array('level' => $level[$key], 'school_name' => $schoolname[$key], 'date_grad' => $yeargrad[$key], 'school_address' => $schooladd[$key]));
         $applicant->educXps()->save($educxp);
     }
     //get work experience(s)
     $position = Input::get('position');
     $company = Input::get('company_name');
     $task = Input::get('task_description');
     $start = Input::get('date_started');
     $end = Input::get('date_ended');
     //add each work to the current profile
     foreach ($position as $key => $n) {
         $workxp = new WorkXp(array('position' => $position[$key], 'company_name' => $company[$key], 'task_description' => $task[$key], 'date_started' => $start[$key], 'date_ended' => $end[$key]));
         $applicant->workXps()->save($workxp);
     }
     $code = Code::find(session('newCode')[0]['id']);
     $code->update(['status' => 1]);
     $applicant->code()->save($code);
     session()->forget('newCode');
     return \Redirect::route('form.index')->with('message', 'Your application has been created!');
 }