mardi 4 octobre 2016

Implement Progress Bar in Laravel 5.1

I was developed an admin panel for a job portal application.I am stuck with a problem right now.I want to implement a progress bar in applicant list view.That progress bar will indicate the amount of applicant profile completion.I was querying data from my dependent tables and I want calculate the percentage in real time.Here is my code spinet. Please give me a solution that how can I calculate the percentage of profile complition.Thank you in advance.

public function index()
    {
        $applicant_data = array();
        $applicant_result = array();
        $profile_array = array();
        $applicants = Applicant::leftJoin('applicant_jobs', 'applicant_jobs.uid' , '=', 'applicant.uid')
                ->leftJoin('applicant_profile', 'applicant_profile.uid' , '=', 'applicant.uid')
                ->leftJoin('recruiter', 'applicant_jobs.rid' , '=', 'recruiter.rid')
                ->leftJoin('recruitment', 'applicant_jobs.id_job' , '=', 'recruitment.id_job')
                ->orderBy('applicant.create_time', 'desc')
                ->groupBy('applicant.uid')
                ->select('applicant.*', 'applicant_profile.*', 'applicant_jobs.id_job', 'applicant.create_time as applicantRegTime',
                    DB::raw('(SELECT COUNT(applicant_jobs.status) FROM applicant_jobs WHERE applicant_jobs.status = 0 AND applicant_jobs.uid = applicant.uid) AS savedJobs'),
                    DB::raw('(SELECT COUNT(applicant_jobs.status) FROM applicant_jobs WHERE applicant_jobs.status = 1 AND applicant_jobs.uid = applicant.uid) AS appliedJobs'),
                    DB::raw('(SELECT lv.education_level_name FROM `education` AS e INNER JOIN education_level AS lv ON e.education_level_id = lv.education_level_id WHERE e.uid = applicant.uid ORDER BY e.education_id ASC LIMIT 1) AS lastLevelOfEducation'),
                    DB::raw('(SELECT ins.institute_name FROM `education` AS e INNER JOIN institute AS ins ON e. institute_id = ins.institute_id WHERE e.uid = applicant.uid ORDER BY e.education_id ASC LIMIT 1) AS lastInstitute'),
                    DB::raw('(SELECT education_group_name FROM `education` WHERE uid = applicant.uid ORDER BY education_id ASC LIMIT 1) AS lastEducationMajor'),
                    DB::raw('(SELECT emp.position FROM `applicant_employment` AS emp WHERE emp.uid = applicant.uid ORDER BY emp.employment_id ASC LIMIT 1) AS lastExpDesignation'),
                    DB::raw('(SELECT emp.company_name FROM `applicant_employment` AS emp WHERE emp.uid = applicant.uid ORDER BY emp.employment_id ASC LIMIT 1) AS lastExpCompany'))
                ->get();

        foreach($applicants as $applicant)
        {
            $progress_result = 0;
            $applicant_data['name'] = $applicant->name;
            $applicant_data['email'] = $applicant->email;
            $applicant_data['phone'] = $applicant->phone;
            $applicant_data['savedJobs'] = $applicant->savedJobs;
            $applicant_data['appliedJobs'] = $applicant->appliedJobs;
            $applicant_data['applicantRegTime'] = date('d-m-Y', strtotime($applicant->applicantRegTime));
            $applicant_data['lastLevelOfEducation'] = $applicant->lastLevelOfEducation;
            $applicant_data['lastInstitute'] = $applicant->lastInstitute;
            $applicant_data['lastEducationMajor'] = $applicant->lastEducationMajor;
            if($applicant->lastExpDesignation)
            {
                $applicant_data['experience'] = $applicant->lastExpDesignation.' at '.$applicant->lastExpCompany;
            }
            if($applicant->skills){
                $applicant_data['skills'] = $applicant->skills;
            }
            if($applicant->cv_file_path){
                $applicant_data['cv_file_path'] = $applicant->cv_file_path;
            }
            $applicant_profile_data = ApplicantProfile::where('uid', $applicant->id)->select('present_address', 'permanent_address', 'special_qual','career_summary')->first();
            if($applicant_profile_data){
                $applicant_data['progressBar'] = $progress_result + 15;
            }else{
                $applicant_data['progressBar'] = $progress_result + 0;
            }

            $education_data = Education::where('uid', $applicant->uid)->get();
            if(isset($education_data))
            {
                $applicant_data['progressBar'] = $progress_result + 15;
            }else{
                $applicant_data['progressBar'] = $progress_result + 0;
            }
            array_push($applicant_result, $applicant_data);
        }

        return view('user.index', compact('applicant_result'));
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire