app/Http/Controllers/Admin/Pegawai/PegawaiController.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(Request $req)
    {
        $data['pegawai'] = User::leftJoin('indikator_kerjas', 'users.id', 'indikator_kerjas.users_id')
            ->leftJoin('uraian_kegiatans', 'indikator_kerjas.id', 'uraian_kegiatans.id_indikator_kerjas')
            ->leftJoin('trans_indikator_kinerjas', 'uraian_kegiatans.id', 'trans_indikator_kinerjas.id_uraian_kegiatan')
            ->leftJoin('kehadirans', 'users.id', 'kehadirans.users_id')
            ->where('users.role', 'pegawai')
            ->where('users.status', 1)
            ->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 ) as pra_nilai_capaian'),
                DB::raw('((avg((uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi) / 2 ) + avg(kehadirans.nilai)) / 2) as nilai_capaian'),
                DB::raw('avg((uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi)) as nilai_perhitungan')
            ])->groupBy('users.id')->get();
        if ($req->is_api) {
            return response()->json($data, 200);
        } else {
            $data['page_title'] = 'Pegawai';
            $data['i'] = 1;
            return view('admin.pegawai')->with($data);
        }
    }
public function index ( Request $ req ) { $ data [ 'pegawai' ] = User :: leftJoin ( 'indikator_kerjas' , 'users.id' , 'indikator_kerjas.users_id' ) -> leftJoin ( 'uraian_kegiatans' , 'indikator_kerjas.id' , 'uraian_kegiatans.id_indikator_kerjas' ) -> leftJoin ( 'trans_indikator_kinerjas' , 'uraian_kegiatans.id' , 'trans_indikator_kinerjas.id_uraian_kegiatan' ) -> leftJoin ( 'kehadirans' , 'users.id' , 'kehadirans.users_id' ) -> where ( 'users.role' , 'pegawai' ) -> where ( 'users.status' , 1 ) -> 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 ) as pra_nilai_capaian' ) , DB :: raw ( '((avg((uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi) / 2 ) + avg(kehadirans.nilai)) / 2) as nilai_capaian' ) , DB :: raw ( 'avg((uraian_kegiatans.mutu_target + uraian_kegiatans.mutu_realisasi)) as nilai_perhitungan' ) ] ) -> groupBy ( 'users.id' ) -> get ( ) ; if ( $ req -> is_api ) { return response ( ) -> json ( $ data , 200 ) ; } else { $ data [ 'page_title' ] = 'Pegawai' ; $ data [ 'i' ] = 1 ; return view ( 'admin.pegawai' ) -> with ( $ data ) ; } }
Show the application dashboard.
Show the application dashboard .
// $data['pegawai'] = User::where('role', 'pegawai')->where('status', 1)->get();