app/Http/Controllers/CentralController.php
/*
     * update central office or head off central
     */
update central office or head off central
update central office or head off central
public function update( Request $request){
        try{
            if( !$request->input('central_id'))
                throw new Exception("Central Id required for update");
            $centralOffice = CentralOffice::find( $request->input('central_id'));
            if( !$centralOffice )
                throw new Exception("Central office not found with this id");
            $centralName = $request->input('central_name');
            if( $centralName == '' )
                throw new Exception("Minimum central name length need 2");
            $centralOffice->central_name = $centralName;
            $centralOffice->central_details = $request->input('central_details') ? $request->input('central_details') : $centralOffice->cental_details;
            $centralOffice->save();
            return ['success'=>true, 'message'=>"Central office save!", 'data'=>$centralOffice ];
        }catch (Exception $e){
            return ['success'=>false, 'message'=>$e->getMessage()];
        }
    }
public function update ( Request $ request ) { try { if ( ! $ request -> input ( 'central_id' ) ) throw new Exception ( " Central Id required for update " ) ; $ centralOffice = CentralOffice :: find ( $ request -> input ( 'central_id' ) ) ; if ( ! $ centralOffice ) throw new Exception ( " Central office not found with this id " ) ; $ centralName = $ request -> input ( 'central_name' ) ; if ( $ centralName == '' ) throw new Exception ( " Minimum central name length need 2 " ) ; $ centralOffice -> central_name = $ centralName ; $ centralOffice -> central_details = $ request -> input ( 'central_details' ) ? $ request -> input ( 'central_details' ) : $ centralOffice -> cental_details ; $ centralOffice -> save ( ) ; return [ 'success' => true , 'message' => " Central office save! " , 'data' => $ centralOffice ] ; } catch ( Exception $ e ) { return [ 'success' => false , 'message' => $ e -> getMessage ( ) ] ; } }
update central office or head off central
update central office or head off central