app/Http/Controllers/CustomerGroupController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        if (!auth()->user()->can('customer.create')) {
            abort(403, 'Unauthorized action.');
        }
        try {
            $input = $request->only(['name', 'amount']);
            $input['business_id'] = $request->session()->get('user.business_id');
            $input['created_by'] = $request->session()->get('user.id');
            $subscription_cost = !empty($request['subscription_amout']) ? $this->commonUtil->num_uf($request['subscription_amout']) : 0;
            $subscription_pieces = $subscription_cost + $subscription_cost * (25/100);
            $input['amount'] = !empty($input['amount']) ? $this->commonUtil->num_uf($input['amount']) : 0;
            $customer_group = CustomerGroup::create($input);
            $upCusGrp = CustomerGroup::where('id', $customer_group->id)
                ->update(
                    [
                        'subscription_cost' => $subscription_cost,
                        'subscription_pieces' => $subscription_pieces,
                    ]
                );
            $output = ['success' => true,
                            'data' => $customer_group,
                            '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 store ( Request $ request ) { if ( ! auth ( ) -> user ( ) -> can ( 'customer.create' ) ) { abort ( 403 , 'Unauthorized action.' ) ; } try { $ input = $ request -> only ( [ 'name' , 'amount' ] ) ; $ input [ 'business_id' ] = $ request -> session ( ) -> get ( 'user.business_id' ) ; $ input [ 'created_by' ] = $ request -> session ( ) -> get ( 'user.id' ) ; $ subscription_cost = ! empty ( $ request [ 'subscription_amout' ] ) ? $ this -> commonUtil -> num_uf ( $ request [ 'subscription_amout' ] ) : 0 ; $ subscription_pieces = $ subscription_cost + $ subscription_cost * ( 25 / 100 ) ; $ input [ 'amount' ] = ! empty ( $ input [ 'amount' ] ) ? $ this -> commonUtil -> num_uf ( $ input [ 'amount' ] ) : 0 ; $ customer_group = CustomerGroup :: create ( $ input ) ; $ upCusGrp = CustomerGroup :: where ( 'id' , $ customer_group -> id ) -> update ( [ 'subscription_cost' => $ subscription_cost , 'subscription_pieces' => $ subscription_pieces , ] ) ; $ output = [ 'success' => true , 'data' => $ customer_group , '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 ; }
Store a newly created resource in storage.
Store a newly created resource in storage .