app/Http/Controllers/PersonnelController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index(Request $request, Personnel $personnels)
    {
        $officer_index = "PEROFFREG";
        if($officer_index == "PEROFFREG")
        {
            $title_card_header = "Regular Officers";
            $total_personnels = Personnel::join('rf_unitcode', 'rf_unitcode.cg_unitcode', '=', 'tr_master.UnitCode')            
                                    ->where('rf_unitcode.unitgroup_code', 'ASR')
                                    ->where('tr_master.pergroupname', 'PEROFFREG')
                                    ->where('tr_master.UnitCode', Auth::user()->unitcode)
                                    ->count();
            $personnels = Personnel::leftJoin('tr_sll', 'tr_master.afpsn', '=', 'tr_sll.afpsn')  
                                    ->leftJoin('rf_unitcode', 'tr_master.UnitCode', '=', 'rf_unitcode.cg_unitcode')  
                                    ->leftJoin('rf_rank', 'tr_master.rankcode', '=', 'rf_rank.rankcode')          
                                    ->where('rf_unitcode.unitgroup_code', 'ASR')
                                    ->where('tr_master.pergroupname', $officer_index)
                                    ->where('tr_master.UnitCode', Auth::user()->unitcode)
                                    ->groupBy('tr_master.PMCode',
                                            'tr_master.afpsn',
                                            'tr_master.rankcode',
                                            'tr_master.dutycode',
                                            'tr_master.pisunitcode',
                                            'tr_master.middleinitials',
                                            'tr_master.birthday',
                                            'tr_master.dutymodecode',
                                            'tr_master.sllnumber',
                                            'tr_master.pergroupname',
                                            'tr_master.firstname',
                                            'tr_master.middlename',
                                            'tr_master.lastname',
                                            'tr_master.appendage',
                                            'tr_master.afposmoscode',
                                            'tr_master.UnitCode',
                                            'tr_master.shoesize',
                                            'tr_master.shoewidth',
                                            'tr_master.headgear',
                                            'tr_master.bda',
                                            'tr_master.goa',
                                            'tr_master.goachest',
                                            'tr_master.goawaist',
                                            'tr_master.shoesizecombat',
                                            'tr_master.shoewidthcombat',
                                            'tr_master.shirtsize',
                                            'tr_master.pamu_code',
                                            'tr_master.date_updated',
                                            'tr_master.reg_status',
                                            'tr_master.pmcode (1)',
                                            'tr_master.unitcode (1)',
                                            'tr_sll.seniority',
                                            'tr_sll.pmcode',
                                            'tr_sll.fullname',
                                            'tr_sll.rank',
                                            'tr_sll.afpsn',
                                            'tr_sll.afpos',
                                            'tr_sll.sig',
                                            'tr_sll.dor',
                                            'tr_sll.tacs',
                                            'tr_sll.doc',
                                            'tr_sll.dob',
                                            'tr_sll.doret_orig',
                                            'tr_sll.hcc',
                                            'tr_sll.source',
                                            'tr_sll.officer_type',
                                            'tr_sll.authority',
                                            'tr_sll.isDelete',
                                            'tr_sll.remarks',
                                            'tr_sll.remarksdelete',
                                            'tr_sll.remarksalter',
                                            'tr_sll.remarksrestore',
                                            'tr_sll.remarksafpos',
                                            'tr_sll.dau',
                                            'tr_sll.gender',
                                            'tr_sll.dapda',
                                            'tr_sll.designation',
                                            'tr_sll.remarkschooling',
                                            'tr_sll.UnitCode',
                                            'tr_sll.civilstatus',
                                            'tr_sll.specialization',
                                            'tr_sll.integree',
                                            'tr_sll.reg_status',
                                            'tr_sll.date_promoted',
                                            'tr_sll.ethniccode',
                                            'tr_sll.religioncode',
                                            'tr_sll.regioncode',
                                            'tr_sll.date_updated',
                                            'rf_unitcode.cg_unitcode',
                                            'rf_unitcode.recordnumber',
                                            'rf_unitcode.unit_description',
                                            'rf_unitcode.unitgroup_code',
                                            'rf_unitcode.camp_id',
                                            'rf_rank.rankcode',
                                            'rf_rank.rank',
                                            'rf_rank.rankdesc',
                                            'rf_rank.ranking',
                                            'rf_rank.ranktype'
                                            )  
                                    ->orderBy('rf_rank.ranking');
            $dutycodes = DutyCode::orderby('dutycode')->distinct()->get();
        }
        $search = $request->get('search');
        if ($search != "") {
            $personnels = Personnel::join('rf_unitcode', 'rf_unitcode.cg_unitcode', '=', 'tr_master.UnitCode')
                                   ->where('rf_unitcode.unitgroup_code', 'ASR')
                                   ->where('tr_master.pergroupname', $officer_index)
                                   ->where('tr_master.UnitCode', Auth::user()->unitcode)
                                   ->where('afpsn', 'LIKE', '%' . $search . '%')
                                   ->paginate(10)
                                   ->setPath('');
            if (isset($personnels)) {
                $pagination = $personnels->appends(array(
                    'search' => $request->get('search')
                ));
                if (count($personnels) > 0) {
                    return view('pages.personnels.index', 
                    [
                        'title_card_header' => $title_card_header,
                        'total_personnels' => $total_personnels,
                        'dutycodes' => $dutycodes,
                        'personnels' => $personnels
                    ])
                    ->withStatus($personnels)->withQuery($search);
                }
                $records = 'No';
                return view('pages.personnels.index', 
                [
                    'records' => $records, 
                    'title_card_header' => $title_card_header,
                    'total_personnels' => $total_personnels,
                    'dutycodes' => $dutycodes,
                    'personnels' => $personnels
                ])
                ->withStatus($personnels)
                ->withQuery($search);
            }
        }
        return view('pages.personnels.index', 
        [
            'title_card_header' => $title_card_header,
            'total_personnels' => $total_personnels,
            'dutycodes' => $dutycodes,
            'personnels' => $personnels->paginate(10)
        ]);
    }
public function index ( Request $ request , Personnel $ personnels ) { $ officer_index = " PEROFFREG " ; if ( $ officer_index == " PEROFFREG " ) { $ title_card_header = " Regular Officers " ; $ total_personnels = Personnel :: join ( 'rf_unitcode' , 'rf_unitcode.cg_unitcode' , '=' , 'tr_master.UnitCode' ) -> where ( 'rf_unitcode.unitgroup_code' , 'ASR' ) -> where ( 'tr_master.pergroupname' , 'PEROFFREG' ) -> where ( 'tr_master.UnitCode' , Auth :: user ( ) -> unitcode ) -> count ( ) ; $ personnels = Personnel :: leftJoin ( 'tr_sll' , 'tr_master.afpsn' , '=' , 'tr_sll.afpsn' ) -> leftJoin ( 'rf_unitcode' , 'tr_master.UnitCode' , '=' , 'rf_unitcode.cg_unitcode' ) -> leftJoin ( 'rf_rank' , 'tr_master.rankcode' , '=' , 'rf_rank.rankcode' ) -> where ( 'rf_unitcode.unitgroup_code' , 'ASR' ) -> where ( 'tr_master.pergroupname' , $ officer_index ) -> where ( 'tr_master.UnitCode' , Auth :: user ( ) -> unitcode ) -> groupBy ( 'tr_master.PMCode' , 'tr_master.afpsn' , 'tr_master.rankcode' , 'tr_master.dutycode' , 'tr_master.pisunitcode' , 'tr_master.middleinitials' , 'tr_master.birthday' , 'tr_master.dutymodecode' , 'tr_master.sllnumber' , 'tr_master.pergroupname' , 'tr_master.firstname' , 'tr_master.middlename' , 'tr_master.lastname' , 'tr_master.appendage' , 'tr_master.afposmoscode' , 'tr_master.UnitCode' , 'tr_master.shoesize' , 'tr_master.shoewidth' , 'tr_master.headgear' , 'tr_master.bda' , 'tr_master.goa' , 'tr_master.goachest' , 'tr_master.goawaist' , 'tr_master.shoesizecombat' , 'tr_master.shoewidthcombat' , 'tr_master.shirtsize' , 'tr_master.pamu_code' , 'tr_master.date_updated' , 'tr_master.reg_status' , 'tr_master.pmcode (1)' , 'tr_master.unitcode (1)' , 'tr_sll.seniority' , 'tr_sll.pmcode' , 'tr_sll.fullname' , 'tr_sll.rank' , 'tr_sll.afpsn' , 'tr_sll.afpos' , 'tr_sll.sig' , 'tr_sll.dor' , 'tr_sll.tacs' , 'tr_sll.doc' , 'tr_sll.dob' , 'tr_sll.doret_orig' , 'tr_sll.hcc' , 'tr_sll.source' , 'tr_sll.officer_type' , 'tr_sll.authority' , 'tr_sll.isDelete' , 'tr_sll.remarks' , 'tr_sll.remarksdelete' , 'tr_sll.remarksalter' , 'tr_sll.remarksrestore' , 'tr_sll.remarksafpos' , 'tr_sll.dau' , 'tr_sll.gender' , 'tr_sll.dapda' , 'tr_sll.designation' , 'tr_sll.remarkschooling' , 'tr_sll.UnitCode' , 'tr_sll.civilstatus' , 'tr_sll.specialization' , 'tr_sll.integree' , 'tr_sll.reg_status' , 'tr_sll.date_promoted' , 'tr_sll.ethniccode' , 'tr_sll.religioncode' , 'tr_sll.regioncode' , 'tr_sll.date_updated' , 'rf_unitcode.cg_unitcode' , 'rf_unitcode.recordnumber' , 'rf_unitcode.unit_description' , 'rf_unitcode.unitgroup_code' , 'rf_unitcode.camp_id' , 'rf_rank.rankcode' , 'rf_rank.rank' , 'rf_rank.rankdesc' , 'rf_rank.ranking' , 'rf_rank.ranktype' ) -> orderBy ( 'rf_rank.ranking' ) ; $ dutycodes = DutyCode :: orderby ( 'dutycode' ) -> distinct ( ) -> get ( ) ; } $ search = $ request -> get ( 'search' ) ; if ( $ search != " " ) { $ personnels = Personnel :: join ( 'rf_unitcode' , 'rf_unitcode.cg_unitcode' , '=' , 'tr_master.UnitCode' ) -> where ( 'rf_unitcode.unitgroup_code' , 'ASR' ) -> where ( 'tr_master.pergroupname' , $ officer_index ) -> where ( 'tr_master.UnitCode' , Auth :: user ( ) -> unitcode ) -> where ( 'afpsn' , 'LIKE' , '%' . $ search . '%' ) -> paginate ( 10 ) -> setPath ( '' ) ; if ( isset ( $ personnels ) ) { $ pagination = $ personnels -> appends ( array ( 'search' => $ request -> get ( 'search' ) ) ) ; if ( count ( $ personnels ) > 0 ) { return view ( 'pages.personnels.index' , [ 'title_card_header' => $ title_card_header , 'total_personnels' => $ total_personnels , 'dutycodes' => $ dutycodes , 'personnels' => $ personnels ] ) -> withStatus ( $ personnels ) -> withQuery ( $ search ) ; } $ records = 'No' ; return view ( 'pages.personnels.index' , [ 'records' => $ records , 'title_card_header' => $ title_card_header , 'total_personnels' => $ total_personnels , 'dutycodes' => $ dutycodes , 'personnels' => $ personnels ] ) -> withStatus ( $ personnels ) -> withQuery ( $ search ) ; } } return view ( 'pages.personnels.index' , [ 'title_card_header' => $ title_card_header , 'total_personnels' => $ total_personnels , 'dutycodes' => $ dutycodes , 'personnels' => $ personnels -> paginate ( 10 ) ] ) ; }
Display a listing of the resource.
Display a listing of the resource .