app/Http/Controllers/DistrictController.php
/*
     * update district office or head off district
     */
update district office or head off district
update district office or head off district
public function update( Request $request){
        try{
            if( !$request->input('district_id'))
                throw new Exception("district Id required for update");
            $districtOffice = DistrictOffice::find( $request->input('district_id'));
            if( !$districtOffice )
                throw new Exception("district office not found with this id");
            $districtName = $request->input('district_name');
            if( $districtName == '' )
                throw new Exception("Minimum district name length need 2");
            $districtOffice->district_name = $districtName;
            $districtOffice->district_details = $request->input('district_details') ? $request->input('district_details') : $districtOffice->district_details;
            $districtOffice->save();
            return ['success'=>true, 'message'=>"district office save!", 'data'=>$districtOffice ];
        }catch (Exception $e){
            return ['success'=>false, 'message'=>$e->getMessage()];
        }
    }
public function update ( Request $ request ) { try { if ( ! $ request -> input ( 'district_id' ) ) throw new Exception ( " district Id required for update " ) ; $ districtOffice = DistrictOffice :: find ( $ request -> input ( 'district_id' ) ) ; if ( ! $ districtOffice ) throw new Exception ( " district office not found with this id " ) ; $ districtName = $ request -> input ( 'district_name' ) ; if ( $ districtName == '' ) throw new Exception ( " Minimum district name length need 2 " ) ; $ districtOffice -> district_name = $ districtName ; $ districtOffice -> district_details = $ request -> input ( 'district_details' ) ? $ request -> input ( 'district_details' ) : $ districtOffice -> district_details ; $ districtOffice -> save ( ) ; return [ 'success' => true , 'message' => " district office save! " , 'data' => $ districtOffice ] ; } catch ( Exception $ e ) { return [ 'success' => false , 'message' => $ e -> getMessage ( ) ] ; } }
update district office or head off district
update district office or head off district