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