has('license_key') && $request->has('product_id') ) { $license_key = $request->input('license_key'); $product_id = $request->input('product_id'); $url = config('ninja.license_url') . "/claim_license?license_key={$license_key}&product_id={$product_id}&get_date=true"; $data = trim(CurlUtils::get($url)); if ($data == Account::RESULT_FAILURE) { $error = [ 'message' => trans('texts.invalid_white_label_license'), 'errors' => [] ]; return response()->json($error, 400); } elseif ($data) { $date = date_create($data)->modify('+1 year'); if ($date < date_create()) { $error = [ 'message' => trans('texts.invalid_white_label_license'), 'errors' => [] ]; return response()->json($error, 400); } else { $account = auth()->user()->company()->account; $account->plan_term = Account::PLAN_TERM_YEARLY; $account->plan_paid = $data; $account->plan_expires = $date->format('Y-m-d'); $account->plan = Account::PLAN_WHITE_LABEL; $account->save(); $error = [ 'message' => trans('texts.bought_white_label'), 'errors' => [] ]; return response()->json($error, 200); } } else { $error = [ 'message' => trans('texts.white_label_license_error'), 'errors' => [] ]; return response()->json($error, 400); } } $error = [ 'message' => trans('texts.invalid_white_label_license'), 'errors' => [] ]; return response()->json($error, 400); } }