app/Http/Controllers/CustomerGroupController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        if (!auth()->user()->can('customer.update')) {
            abort(403, 'Unauthorized action.');
        }
        if (request()->ajax()) {
            try {
                $input = $request->only(['name', 'amount']);
                $business_id = $request->session()->get('user.business_id');
                $input['amount'] = !empty($input['amount']) ? $this->commonUtil->num_uf($input['amount']) : 0;
                $customer_group = CustomerGroup::where('business_id', $business_id)->findOrFail($id);
                $customer_group->name = $input['name'];
                $customer_group->amount = $input['amount'];
                $customer_group->subscription_cost = $request['subscription_amout'];
                $percent = $request['subscription_amout'] * (25/100);
                $offer = $percent + $request['subscription_amout'];
                $customer_group->subscription_pieces = $offer;
                $customer_group->save();
                $output = ['success' => true,
                            'msg' => __("lang_v1.success")
                            ];
            } catch (\Exception $e) {
                \Log::emergency("File:" . $e->getFile(). "Line:" . $e->getLine(). "Message:" . $e->getMessage());
                $output = ['success' => false,
                            'msg' => __("messages.something_went_wrong")
                        ];
            }
            return $output;
        }
    }
public function update ( Request $ request , $ id ) { if ( ! auth ( ) -> user ( ) -> can ( 'customer.update' ) ) { abort ( 403 , 'Unauthorized action.' ) ; } if ( request ( ) -> ajax ( ) ) { try { $ input = $ request -> only ( [ 'name' , 'amount' ] ) ; $ business_id = $ request -> session ( ) -> get ( 'user.business_id' ) ; $ input [ 'amount' ] = ! empty ( $ input [ 'amount' ] ) ? $ this -> commonUtil -> num_uf ( $ input [ 'amount' ] ) : 0 ; $ customer_group = CustomerGroup :: where ( 'business_id' , $ business_id ) -> findOrFail ( $ id ) ; $ customer_group -> name = $ input [ 'name' ] ; $ customer_group -> amount = $ input [ 'amount' ] ; $ customer_group -> subscription_cost = $ request [ 'subscription_amout' ] ; $ percent = $ request [ 'subscription_amout' ] * ( 25 / 100 ) ; $ offer = $ percent + $ request [ 'subscription_amout' ] ; $ customer_group -> subscription_pieces = $ offer ; $ customer_group -> save ( ) ; $ output = [ 'success' => true , 'msg' => __ ( " lang_v1.success " ) ] ; } catch ( \ Exception $ e ) { \ Log :: emergency ( " File: " . $ e -> getFile ( ) . " Line: " . $ e -> getLine ( ) . " Message: " . $ e -> getMessage ( ) ) ; $ output = [ 'success' => false , 'msg' => __ ( " messages.something_went_wrong " ) ] ; } return $ output ; } }
Update the specified resource in storage.
Update the specified resource in storage .