app/Http/Controllers/HomeController.php
/**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
Show the application dashboard.
@return \Illuminate\Contracts\Support\Renderable
Show the application dashboard . @return \ Illuminate \ Contracts \ Support \ Renderable
public function index()
    {
        return redirect()->route('envelope');
        $bulanan = User::rightJoin('indikator_kerjas', 'users.id', 'indikator_kerjas.users_id')
            ->leftJoin('uraian_kegiatans', 'indikator_kerjas.id', 'uraian_kegiatans.id_indikator_kerjas')                    
            ->where('users.role', 'pegawai')                        
            ->select([
                'users.id',
                'users.nama',
                'users.golongan',
                'users.jabatan',
                'users.unit_kerja',
                'users.nip',                
                DB::raw('(avg(uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi) / 2  ) /  count(indikator_kerjas.id) as nilai_capaian'),
                DB::raw('avg(uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi) as nilai_perhitungan'),
                DB::raw('month(indikator_kerjas.created_at) as month'),                
            ])->groupBy('month')->orderBy('month')->get();        
        $tahunan = User::rightJoin('indikator_kerjas', 'users.id', 'indikator_kerjas.users_id')
            ->leftJoin('uraian_kegiatans', 'indikator_kerjas.id', 'uraian_kegiatans.id_indikator_kerjas')            
            ->where('users.role', 'pegawai')                        
            ->select([
                'users.id',
                'users.nama',
                'users.golongan',
                'users.jabatan',
                'users.unit_kerja',
                'users.nip',                
                DB::raw('(avg(uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi) / 2  ) /  count(indikator_kerjas.id) as nilai_capaian'),
                DB::raw('avg((uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi)) as nilai_perhitungan'),
                DB::raw('year(indikator_kerjas.created_at) as year'),                
            ])->groupBy('year')->orderBy('year')->get();
        $summaries = User::rightJoin('indikator_kerjas', 'users.id', 'indikator_kerjas.users_id')
            ->leftJoin('uraian_kegiatans', 'indikator_kerjas.id', 'uraian_kegiatans.id_indikator_kerjas')                 
            ->where('users.role', 'pegawai')            
            ->select([                
                DB::raw('(avg(uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi) / 2  ) /  count(indikator_kerjas.id) as nilai_capaian'),
                DB::raw('avg((uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi)) as nilai_perhitungan'),                
            ])->get();
        $summary = $summaries->first();
        $monthNames = [];
        $monthlyPerformance = [];
        foreach ($bulanan as $item) {
            $monthNames[] = $this->month($item->month);
            $monthlyPerformance[] = $item->nilai_capaian == null ? 0 : $item->nilai_capaian;
        }
        $yearlyPerformance = [];
        $year =  [];
        foreach ($tahunan as $item) {
            $yearlyPerformance[] = $item->nilai_capaian == null ? 0 : $item->nilai_capaian;
            $year[] = $item->year ==  null ? 0 : $item->year;
        }
        $data['monthly_performance'] = $monthlyPerformance;
        $data['month_names'] = $monthNames;
        $data['kriteria'] = NilaiCapaian::where('nilai_angka_min', '=<', $summary->nilai_capaian)->where('nilai_angka', '=>',  $summary->nilai_capaian)->first();
        $data['summary'] = $summary;
        $data['yearly_performance'] = $yearlyPerformance;
        $data['year'] = $year;
        $data['page_title'] = 'Dashboard';                 
        return view('admin.dashboard')->with($data);
    }
public function index ( ) { return redirect ( ) -> route ( 'envelope' ) ; $ bulanan = User :: rightJoin ( 'indikator_kerjas' , 'users.id' , 'indikator_kerjas.users_id' ) -> leftJoin ( 'uraian_kegiatans' , 'indikator_kerjas.id' , 'uraian_kegiatans.id_indikator_kerjas' ) -> where ( 'users.role' , 'pegawai' ) -> select ( [ 'users.id' , 'users.nama' , 'users.golongan' , 'users.jabatan' , 'users.unit_kerja' , 'users.nip' , DB :: raw ( '(avg(uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi) / 2  ) /  count(indikator_kerjas.id) as nilai_capaian' ) , DB :: raw ( 'avg(uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi) as nilai_perhitungan' ) , DB :: raw ( 'month(indikator_kerjas.created_at) as month' ) , ] ) -> groupBy ( 'month' ) -> orderBy ( 'month' ) -> get ( ) ; $ tahunan = User :: rightJoin ( 'indikator_kerjas' , 'users.id' , 'indikator_kerjas.users_id' ) -> leftJoin ( 'uraian_kegiatans' , 'indikator_kerjas.id' , 'uraian_kegiatans.id_indikator_kerjas' ) -> where ( 'users.role' , 'pegawai' ) -> select ( [ 'users.id' , 'users.nama' , 'users.golongan' , 'users.jabatan' , 'users.unit_kerja' , 'users.nip' , DB :: raw ( '(avg(uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi) / 2  ) /  count(indikator_kerjas.id) as nilai_capaian' ) , DB :: raw ( 'avg((uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi)) as nilai_perhitungan' ) , DB :: raw ( 'year(indikator_kerjas.created_at) as year' ) , ] ) -> groupBy ( 'year' ) -> orderBy ( 'year' ) -> get ( ) ; $ summaries = User :: rightJoin ( 'indikator_kerjas' , 'users.id' , 'indikator_kerjas.users_id' ) -> leftJoin ( 'uraian_kegiatans' , 'indikator_kerjas.id' , 'uraian_kegiatans.id_indikator_kerjas' ) -> where ( 'users.role' , 'pegawai' ) -> select ( [ DB :: raw ( '(avg(uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi) / 2  ) /  count(indikator_kerjas.id) as nilai_capaian' ) , DB :: raw ( 'avg((uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi)) as nilai_perhitungan' ) , ] ) -> get ( ) ; $ summary = $ summaries -> first ( ) ; $ monthNames = [ ] ; $ monthlyPerformance = [ ] ; foreach ( $ bulanan as $ item ) { $ monthNames [ ] = $ this -> month ( $ item -> month ) ; $ monthlyPerformance [ ] = $ item -> nilai_capaian == null ? 0 : $ item -> nilai_capaian ; } $ yearlyPerformance = [ ] ; $ year = [ ] ; foreach ( $ tahunan as $ item ) { $ yearlyPerformance [ ] = $ item -> nilai_capaian == null ? 0 : $ item -> nilai_capaian ; $ year [ ] = $ item -> year == null ? 0 : $ item -> year ; } $ data [ 'monthly_performance' ] = $ monthlyPerformance ; $ data [ 'month_names' ] = $ monthNames ; $ data [ 'kriteria' ] = NilaiCapaian :: where ( 'nilai_angka_min' , '=<' , $ summary -> nilai_capaian ) -> where ( 'nilai_angka' , '=>' , $ summary -> nilai_capaian ) -> first ( ) ; $ data [ 'summary' ] = $ summary ; $ data [ 'yearly_performance' ] = $ yearlyPerformance ; $ data [ 'year' ] = $ year ; $ data [ 'page_title' ] = 'Dashboard' ; return view ( 'admin.dashboard' ) -> with ( $ data ) ; }
Show the application dashboard.
Show the application dashboard .