/** * Display a listing of the resource. * * @return Response */ public function index() { $candidates = Candidates::with("user", "experience")->whereHas('user', function ($q) { $q->where('role', 1); })->get(); // shoud thake from candidates return response()->json($candidates); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $candidates = Candidates::all(); $count = DB::table('votes')->count(); $count15 = DB::table('votes')->where('angkatan', '2015')->count(); $count14 = DB::table('votes')->where('angkatan', '2014')->count(); $count13 = DB::table('votes')->where('angkatan', '2013')->count(); $count12 = DB::table('votes')->where('angkatan', '2012')->count(); $coba = DB::select('SELECT candidate_id, DATE(created_at) as date, COUNT(username) AS count FROM votes GROUP BY candidate_id, DATE(created_at) ORDER BY DATE(created_at), candidate_id'); $quick = DB::select('SELECT candidate_id, COUNT(username) AS count FROM votes GROUP BY candidate_id ORDER BY candidate_id'); $angkatan = array('agk15' => $count15, 'agk14' => $count14, 'agk13' => $count13, 'agk12' => $count12); return view('admin.layout.index', ['count' => $count, 'angkatan' => $angkatan, 'coba' => $coba, 'quick' => $quick, 'candidates' => $candidates]); }
public function actionUpload() { $candidateID = intval($_POST['candidateID']); $Candidate = Candidates::findOne($candidateID); if (!$Candidate) { echo 0; die; } $finalDir = '/home/ubuntu/workspace/basic/uploads/' . $Candidate->id; if (!is_dir($finalDir)) { mkdir($finalDir); } $CandidatesFiles = new CandidatesFiles(); $CandidatesFiles->candidate_id = $Candidate->id; $CandidatesFiles->original_filename = basename($_FILES['uploadedFile']['name']); $CandidatesFiles->server_filename = time() . "_" . $CandidatesFiles->original_filename; if (move_uploaded_file($_FILES['uploadedFile']['tmp_name'], $finalDir . "/" . $CandidatesFiles->server_filename)) { // HP Store object $fileUrl = Url::to('@web/uploads/' . $Candidate->id . '/' . $CandidatesFiles->server_filename, true); $CandidatesFiles->hp_reference_id = Yii::$app->HpApi->storeObject($fileUrl); $CandidatesFiles->save(); // Resumes object $Resumes = new Resumes(); $Resumes->candidate_file_id = $CandidatesFiles->id; // HP OCR $Resumes->hp_job_id = Yii::$app->HpApi->ocrDocument($CandidatesFiles->hp_reference_id); $Resumes->save(); // Resumes faces object $ResumesFaces = new ResumesFaces(); $ResumesFaces->resume_id = $Resumes->id; // HP Face Detection $ResumesFaces->hp_job_id = Yii::$app->HpApi->faceDetection($CandidatesFiles->hp_reference_id); $ResumesFaces->save(); echo 1; } else { echo 0; } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $candidate = Candidates::findOrFail($id); $candidate->delete(); return redirect()->back(); }
public function actionIndex() { $candidateModel = new Candidates(); $candidateModel->save(); return $this->render('index', ['candidateID' => $candidateModel->id]); }
public function getCandidates() { return $this->hasOne(Candidates::className(), ['id' => 'candidate_id']); }