Esempio n. 1
0
 public function tambahkandidat(Request $request)
 {
     $input = new Candidate();
     $input->username = $request->input('username');
     $input->password = Hash::make('himitjaya');
     $input->hak_akses = 3;
     $input->nrp_caka = $request->input('nrp_caka');
     $input->nrp_cawaka = $request->input('nrp_cawaka');
     $input->status_upload = 0;
     $input->save();
     return redirect()->action('AdminController@dashboard');
 }
 /**
  * Function to store newly a candidate
  *
  * @param  AddCandidateRequest $request
  * @return Response view
  */
 public function store(AddCandidateRequest $request)
 {
     $candidates = new Candidate();
     $files = new File();
     $requestdata = $request->all();
     $requestdata['date_of_birth'] = $this->convert_datepicker_to_datetimesql($request->get('dateofbirth'));
     $requestdata['date_submit'] = $this->convert_datepicker_to_datetimesql($request->get('datesubmit'));
     $candidates->first_name = $request->get('firstname');
     $candidates->last_name = $request->get('lastname');
     $candidates->date_of_birth = $requestdata['date_of_birth'];
     $candidates->phone = $request->get('phone');
     $candidates->email = $request->get('email');
     $candidates->date_submit = $requestdata['date_submit'];
     $candidates->comment = $requestdata['comment'];
     $candidates->status_record_id = 1;
     $candidates->save();
     $candidates->attachPosition($request['position']);
     $destinationPath = public_path() . '/files/' . $candidates->id;
     for ($i = 0; $i < 10; $i++) {
         if (Input::file('files' . $i)) {
             $file = Input::file('files' . $i);
             $titlefile = $request->get('titlefile' . $i);
             $filename = $file->getClientOriginalName();
             $uploadSuccess = $file->move($destinationPath, $filename);
             $files->create(['candidate_id' => $candidates->id, 'name' => $filename, 'title' => $titlefile]);
         }
     }
     return redirect()->route('candidates.index')->with('messageOk', 'Add candidate successfully!');
 }