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