| Total Complexity | 170 |
| Total Lines | 1257 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like CartController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use CartController, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 21 | class CartController extends BaseCartController |
||
| 22 | { |
||
| 23 | public $templateController; |
||
| 24 | public $product; |
||
| 25 | public $currency; |
||
| 26 | public $addons; |
||
| 27 | public $addonRelation; |
||
| 28 | public $licence; |
||
| 29 | public $tax_option; |
||
| 30 | public $tax_by_state; |
||
| 31 | public $setting; |
||
| 32 | |||
| 33 | public function __construct() |
||
| 34 | { |
||
| 35 | $templateController = new TemplateController(); |
||
| 36 | $this->templateController = $templateController; |
||
| 37 | |||
| 38 | $product = new Product(); |
||
| 39 | $this->product = $product; |
||
| 40 | |||
| 41 | $plan_price = new PlanPrice(); |
||
| 42 | $this->$plan_price = $plan_price; |
||
| 43 | |||
| 44 | $currency = new Currency(); |
||
| 45 | $this->currency = $currency; |
||
| 46 | |||
| 47 | $tax = new Tax(); |
||
| 48 | $this->tax = $tax; |
||
| 49 | |||
| 50 | $setting = new Setting(); |
||
| 51 | $this->setting = $setting; |
||
| 52 | |||
| 53 | $tax_option = new TaxOption(); |
||
| 54 | $this->tax_option = $tax_option; |
||
| 55 | |||
| 56 | $tax_by_state = new TaxByState(); |
||
| 57 | $this->tax_by_state = new $tax_by_state(); |
||
| 58 | |||
| 59 | // $this->middleware('Inatall'); |
||
| 60 | // $this->middleware('admin'); |
||
| 61 | } |
||
| 62 | |||
| 63 | public function productList(Request $request) |
||
| 92 | } |
||
| 93 | } |
||
| 94 | |||
| 95 | public function cart(Request $request) |
||
| 96 | { |
||
| 97 | try { |
||
| 98 | $plan = ''; |
||
| 99 | |||
| 100 | if ($request->has('subscription')) { |
||
| 101 | $plan = $request->get('subscription'); |
||
| 102 | |||
| 103 | Session::put('plan', $plan); |
||
| 104 | } |
||
| 105 | $id = $request->input('id'); |
||
| 106 | |||
| 107 | if (!array_key_exists($id, Cart::getContent())) { |
||
| 108 | $items = $this->addProduct($id); |
||
| 109 | |||
| 110 | Cart::add($items); |
||
| 111 | } |
||
| 112 | |||
| 113 | return redirect('show/cart'); |
||
| 114 | } catch (\Exception $ex) { |
||
| 115 | // dd($ex); |
||
| 116 | return redirect()->back()->with('fails', $ex->getMessage()); |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 120 | public function showCart() |
||
| 160 | } |
||
| 161 | } |
||
| 162 | |||
| 163 | public function checkTax($productid, $user_state = '', $user_country = '') |
||
| 164 | { |
||
| 165 | try { |
||
| 166 | $taxCondition = array(); |
||
| 167 | $tax_attribute = array(); |
||
| 168 | $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0]; |
||
| 169 | $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
||
| 170 | 'name' => 'null', |
||
| 171 | 'type' => 'tax', |
||
| 172 | 'target' => 'item', |
||
| 173 | 'value' => '0%', |
||
| 174 | ]); |
||
| 175 | $cont = new \App\Http\Controllers\Front\GetPageTemplateController(); |
||
| 176 | $location = $cont->getLocation(); |
||
| 177 | |||
| 178 | $country = $this->findCountryByGeoip($location['countryCode']); |
||
| 179 | $states = $this->findStateByRegionId($location['countryCode']); |
||
| 180 | $states = \App\Model\Common\State::pluck('state_subdivision_name', 'state_subdivision_code')->toArray(); |
||
| 181 | $state_code = $location['countryCode'].'-'.$location['region']; |
||
| 182 | $state = $this->getStateByCode($state_code); |
||
| 183 | $mobile_code = $this->getMobileCodeByIso($location['countryCode']); |
||
| 184 | $country_iso = $location['countryCode']; |
||
| 185 | |||
| 186 | $geoip_state = $this->getGeoipState($state_code, $user_state); |
||
| 187 | $geoip_country = $this->getGeoipCountry($country_iso, $user_country); |
||
| 188 | |||
| 189 | |||
| 190 | if ($this->tax_option->findOrFail(1)->inclusive == 0) { |
||
| 191 | $tax_rule = $this->tax_option->findOrFail(1); |
||
| 192 | $shop = $tax_rule->shop_inclusive; |
||
| 193 | $cart = $tax_rule->cart_inclusive; |
||
| 194 | $tax_enable = $this->tax_option->findOrFail(1)->tax_enable; |
||
| 195 | //Check the state of user for calculating GST(cgst,igst,utgst,sgst) |
||
| 196 | $user_state = TaxByState::where('state_code', $geoip_state)->first(); |
||
| 197 | $origin_state = $this->setting->first()->state; //Get the State of origin |
||
| 198 | $tax_class_id = TaxProductRelation::where('product_id', $productid)->pluck('tax_class_id')->toArray(); |
||
| 199 | |||
| 200 | if ($tax_class_id) {//If the product is allowed for tax (Check in tax_product relation table) |
||
| 201 | if ($tax_enable == 1) {//If GST is Enabled |
||
| 202 | |||
| 203 | $state_code = ''; |
||
| 204 | $c_gst = ''; |
||
| 205 | $s_gst = ''; |
||
| 206 | $i_gst = ''; |
||
| 207 | $ut_gst = ''; |
||
| 208 | $value = ''; |
||
| 209 | $rate = ''; |
||
| 210 | $status = 1; |
||
| 211 | |||
| 212 | if ($user_state != '') {//Get the CGST,SGST,IGST,STATE_CODE of the user |
||
| 213 | $c_gst = $user_state->c_gst; |
||
| 214 | $s_gst = $user_state->s_gst; |
||
| 215 | $i_gst = $user_state->i_gst; |
||
| 216 | $ut_gst = $user_state->ut_gst; |
||
| 217 | $state_code = $user_state->state_code; |
||
| 218 | |||
| 219 | if ($state_code == $origin_state) {//If user and origin state are same |
||
| 220 | $rateForSameState = $this->getTaxWhenIndianSameState($user_state, |
||
| 221 | $origin_state, $productid, $c_gst, $s_gst, $state_code, $status); |
||
| 222 | |||
| 223 | $taxes = $rateForSameState['taxes']; |
||
| 224 | $status = $rateForSameState['status']; |
||
| 225 | $value = $rateForSameState['value']; |
||
| 226 | } elseif ($state_code != $origin_state && $ut_gst == 'NULL') {//If user is from other state |
||
| 227 | $rateForOtherState = $this->getTaxWhenIndianOtherState($user_state, |
||
| 228 | $origin_state, $productid, $i_gst, $state_code, $status); |
||
| 229 | $taxes = $rateForOtherState['taxes']; |
||
| 230 | $status = $rateForOtherState['status']; |
||
| 231 | $value = $rateForOtherState['value']; |
||
| 232 | } elseif ($state_code != $origin_state && $ut_gst != 'NULL') {//if user from Union Territory |
||
| 233 | $rateForUnionTerritory = $this->getTaxWhenUnionTerritory($user_state, |
||
| 234 | $origin_state, $productid, $c_gst, $ut_gst, $state_code, $status); |
||
| 235 | $taxes = $rateForUnionTerritory['taxes']; |
||
| 236 | $status = $rateForUnionTerritory['status']; |
||
| 237 | $value = $rateForUnionTerritory['value']; |
||
| 238 | } |
||
| 239 | } else {//If user from other Country |
||
| 240 | $taxClassId = Tax::where('state', $geoip_state) |
||
| 241 | ->orWhere('country', $geoip_country) |
||
| 242 | ->pluck('tax_classes_id')->first(); |
||
| 243 | if ($taxClassId) { //if state equals the user State or country equals user country |
||
| 244 | $taxForSpecificCountry = $this->getTaxForSpecificCountry($taxClassId, |
||
| 245 | $productid, $status); |
||
| 246 | $taxes = $taxForSpecificCountry['taxes']; |
||
| 247 | $status = $taxForSpecificCountry['status']; |
||
| 248 | $value = $taxForSpecificCountry['value']; |
||
| 249 | $rate = $taxForSpecificCountry['value']; |
||
| 250 | } else {//if Tax is selected for Any Country Any State |
||
| 251 | $taxClassId = Tax::where('country', '') |
||
| 252 | ->where('state', 'Any State') |
||
| 253 | ->pluck('tax_classes_id')->first(); |
||
| 254 | if ($taxClassId) { |
||
| 255 | $taxForAnyCountry = $this->getTaxForAnyCountry($taxClassId, $productid, $status); |
||
| 256 | $taxes = $taxForAnyCountry['taxes']; |
||
| 257 | $status = $taxForAnyCountry['status']; |
||
| 258 | $value = $taxForAnyCountry['value']; |
||
| 259 | $rate = $taxForAnyCountry['value']; |
||
| 260 | } else { |
||
| 261 | $taxes = [0]; |
||
| 262 | } |
||
| 263 | } |
||
| 264 | } |
||
| 265 | foreach ($taxes as $key => $tax) { |
||
| 266 | |||
| 267 | //All the da a attribute that is sent to the checkout Page if tax_compound=0 |
||
| 268 | if ($taxes[0]) { |
||
| 269 | $tax_attribute[$key] = ['name' => $tax->name, 'c_gst'=>$c_gst, |
||
| 270 | 's_gst' => $s_gst, 'i_gst'=>$i_gst, 'ut_gst'=>$ut_gst, |
||
| 271 | 'state' => $state_code, 'origin_state'=>$origin_state, |
||
| 272 | 'tax_enable' => $tax_enable, 'rate'=>$value, 'status'=>$status, ]; |
||
| 273 | |||
| 274 | $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
||
| 275 | |||
| 276 | 'name' => 'no compound', |
||
| 277 | 'type' => 'tax', |
||
| 278 | 'target' => 'item', |
||
| 279 | 'value' => $value, |
||
| 280 | ]); |
||
| 281 | } else { |
||
| 282 | $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0]; |
||
| 283 | $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
||
| 284 | 'name' => 'null', |
||
| 285 | 'type' => 'tax', |
||
| 286 | 'target' => 'item', |
||
| 287 | 'value' => '0%', |
||
| 288 | ]); |
||
| 289 | } |
||
| 290 | } |
||
| 291 | } elseif ($tax_enable == 0) {//If Tax enable is 0 |
||
| 292 | $status = 1; |
||
| 293 | if ($this->tax_option->findOrFail(1)->tax_enable == 0) { |
||
| 294 | $taxClassId = Tax::where('country', '') |
||
| 295 | ->where('state', 'Any State') |
||
| 296 | ->pluck('tax_classes_id')->first(); //In case of India when other tax is available and tax is not enabled |
||
| 297 | if ($taxClassId) { |
||
| 298 | $taxes = $this->getTaxByPriority($taxClassId); |
||
| 299 | $value = $this->getValueForOthers($productid, $taxClassId, $taxes); |
||
| 300 | if ($value == 0) { |
||
| 301 | $status = 0; |
||
| 302 | } |
||
| 303 | $rate = $value; |
||
| 304 | foreach ($taxes as $key => $tax) { |
||
| 305 | $tax_attribute[$key] = ['name' => $tax->name, 'rate' => $value, 'tax_enable'=>0, 'status' => $status]; |
||
| 306 | $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([ |
||
| 307 | |||
| 308 | 'name' => $tax->name, |
||
| 309 | 'type' => 'tax', |
||
| 310 | 'target' => 'item', |
||
| 311 | 'value' => $value, |
||
| 312 | ]); |
||
| 313 | } |
||
| 314 | } else {//In case of other country |
||
| 315 | //when tax is available and tax is not enabled |
||
| 316 | //(Applicable when Global Tax class for any country and state is not there) |
||
| 317 | $taxClassId = Tax::where('state', $geoip_state) |
||
| 318 | ->orWhere('country', $geoip_country) |
||
| 319 | ->pluck('tax_classes_id')->first(); |
||
| 320 | if ($taxClassId) { //if state equals the user State |
||
| 321 | $taxes = $this->getTaxByPriority($taxClassId); |
||
| 322 | $value = $this->getValueForOthers($productid, $taxClassId, $taxes); |
||
| 323 | if ($value == '') { |
||
| 324 | $status = 0; |
||
| 325 | } |
||
| 326 | $rate = $value; |
||
| 327 | } |
||
| 328 | foreach ($taxes as $key => $tax) { |
||
| 329 | $tax_attribute[$key] = ['name' => $tax->name, 'rate' => $value, 'tax_enable'=>0, 'status' => $status]; |
||
| 330 | $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([ |
||
| 331 | |||
| 332 | 'name' => $tax->name, |
||
| 333 | 'type' => 'tax', |
||
| 334 | 'target' => 'item', |
||
| 335 | 'value' => $value, |
||
| 336 | ]); |
||
| 337 | } |
||
| 338 | } |
||
| 339 | } |
||
| 340 | } |
||
| 341 | } else { |
||
| 342 | $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0]; |
||
| 343 | $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
||
| 344 | 'name' => 'null', |
||
| 345 | 'type' => 'tax', |
||
| 346 | 'target' => 'item', |
||
| 347 | 'value' => '0%', |
||
| 348 | ]); |
||
| 349 | } |
||
| 350 | } |
||
| 351 | |||
| 352 | $currency_attribute = $this->addCurrencyAttributes($productid); |
||
| 353 | |||
| 354 | return ['conditions' => $taxCondition, |
||
| 355 | 'attributes' => ['tax' => $tax_attribute, |
||
| 356 | 'currency' => $currency_attribute, ], ]; |
||
| 357 | } catch (\Exception $ex) { |
||
| 358 | return redirect()->back()->with('fails',$ex->getMessage()); |
||
| 359 | Bugsnag::notifyException($ex); |
||
| 360 | |||
| 361 | throw new \Exception('Can not check the tax'); |
||
| 362 | } |
||
| 363 | } |
||
| 364 | |||
| 365 | /** |
||
| 366 | * Get tax value for Same State. |
||
| 367 | * |
||
| 368 | * @param type $productid |
||
| 369 | * @param type $c_gst |
||
| 370 | * @param type $s_gst |
||
| 371 | * return type |
||
| 372 | */ |
||
| 373 | public function getValueForSameState($productid, $c_gst, $s_gst, $taxClassId, $taxes) |
||
| 374 | { |
||
| 375 | try { |
||
| 376 | $value = ''; |
||
| 377 | $value = $taxes->toArray()[0]['active'] ? |
||
| 378 | |||
| 379 | (TaxProductRelation::where('product_id', $productid)->where('tax_class_id', $taxClassId)->count() ? |
||
| 380 | $c_gst + $s_gst.'%' : 0) : 0; |
||
| 381 | |||
| 382 | return $value; |
||
| 383 | } catch (Exception $ex) { |
||
| 384 | Bugsnag::notifyException($ex); |
||
| 385 | |||
| 386 | return redirect()->back()->with('fails', $ex->getMessage()); |
||
| 387 | } |
||
| 388 | } |
||
| 389 | |||
| 390 | /** |
||
| 391 | * Get tax value for Other States. |
||
| 392 | * |
||
| 393 | * @param type $productid |
||
| 394 | * @param type $i_gst |
||
| 395 | * return type |
||
| 396 | */ |
||
| 397 | public function getValueForOtherState($productid, $i_gst, $taxClassId, $taxes) |
||
| 398 | { |
||
| 399 | $value = ''; |
||
| 400 | $value = $taxes->toArray()[0]['active'] ? //If the Current Class is active |
||
| 401 | (TaxProductRelation::where('product_id', $productid)->where('tax_class_id', $taxClassId)->count() ? |
||
| 402 | $i_gst.'%' : 0) : 0; //IGST |
||
| 403 | |||
| 404 | return $value; |
||
| 405 | } |
||
| 406 | |||
| 407 | /** |
||
| 408 | * Get tax value for Union Territory States. |
||
| 409 | * |
||
| 410 | * @param type $productid |
||
| 411 | * @param type $c_gst |
||
| 412 | * @param type $ut_gst |
||
| 413 | * return type |
||
| 414 | */ |
||
| 415 | public function getValueForUnionTerritory($productid, $c_gst, $ut_gst, $taxClassId, $taxes) |
||
| 416 | { |
||
| 417 | $value = ''; |
||
| 418 | $value = $taxes->toArray()[0]['active'] ? |
||
| 419 | (TaxProductRelation::where('product_id', $productid)->where('tax_class_id', $taxClassId)->count() ? $ut_gst + $c_gst.'%' : 0) : 0; |
||
| 420 | |||
| 421 | return $value; |
||
| 422 | } |
||
| 423 | |||
| 424 | public function otherRate($productid) |
||
| 425 | { |
||
| 426 | // $taxClassOther = TaxClass::where('name', 'Others')->pluck('id')->toArray(); |
||
| 427 | // $otherRate = TaxProductRelation::where('product_id', $productid)->where('tax_class_id', $taxClassOther)->count() ? Tax::where('tax_classes_id', $taxClassOther)->first()->rate : ''; |
||
| 428 | $otherRate = ''; |
||
| 429 | |||
| 430 | return $otherRate; |
||
| 431 | } |
||
| 432 | |||
| 433 | public function getValueForOthers($productid, $taxClassId, $taxes) |
||
| 434 | { |
||
| 435 | $otherRate = 0; |
||
| 436 | $status = $taxes->toArray()[0]['active']; |
||
| 437 | if ($status && (TaxProductRelation::where('product_id', $productid)->where('tax_class_id', $taxClassId)->count() > 0)) { |
||
| 438 | $otherRate = Tax::where('tax_classes_id', $taxClassId)->first()->rate; |
||
| 439 | } |
||
| 440 | |||
| 441 | // $value= $taxes->toArray()[0]['active'] ? |
||
| 442 | // (TaxProductRelation::where('product_id', $productid)->where('tax_class_id', $taxClassId)->count() != 0) ? |
||
| 443 | // $otherRate = Tax::where('tax_classes_id', $taxClassId)->first()->rate; |
||
| 444 | |||
| 445 | $value = $otherRate.'%'; |
||
| 446 | |||
| 447 | return $value; |
||
| 448 | } |
||
| 449 | |||
| 450 | public function checkTaxOld($isTaxApply, $id) |
||
| 451 | { |
||
| 452 | try { |
||
| 453 | $rate1 = 0; |
||
| 454 | $rate2 = 0; |
||
| 455 | $name1 = 'null'; |
||
| 456 | $name2 = 'null'; |
||
| 457 | |||
| 458 | if ($ruleEnabled) { |
||
| 459 | $enabled = $ruleEnabled->status; |
||
| 460 | $type = $ruleEnabled->type; |
||
| 461 | $compound = $ruleEnabled->compound; |
||
| 462 | if ($enabled == 1 && $type == 'exclusive') { |
||
| 463 | if ($isTaxApply == 1) { |
||
| 464 | $tax1 = $this->tax->where('level', 1)->first(); |
||
| 465 | $tax2 = $this->tax->where('level', 2)->first(); |
||
| 466 | if ($tax1) { |
||
| 467 | $name1 = $tax1->name; |
||
| 468 | $rate1 = $tax1->rate; |
||
| 469 | $taxCondition1 = new \Darryldecode\Cart\CartCondition([ |
||
| 470 | 'name' => $name1, |
||
| 471 | 'type' => 'tax', |
||
| 472 | 'target' => 'item', |
||
| 473 | 'value' => $rate1.'%', |
||
| 474 | ]); |
||
| 475 | } else { |
||
| 476 | $taxCondition1 = new \Darryldecode\Cart\CartCondition([ |
||
| 477 | 'name' => $name1, |
||
| 478 | 'type' => 'tax', |
||
| 479 | 'target' => 'item', |
||
| 480 | 'value' => $rate1, |
||
| 481 | ]); |
||
| 482 | } |
||
| 483 | if ($tax2) { |
||
| 484 | $name2 = $tax2->name; |
||
| 485 | $rate2 = $tax2->rate; |
||
| 486 | $taxCondition2 = new \Darryldecode\Cart\CartCondition([ |
||
| 487 | 'name' => $name2, |
||
| 488 | 'type' => 'tax', |
||
| 489 | 'target' => 'item', |
||
| 490 | 'value' => $rate2.'%', |
||
| 491 | ]); |
||
| 492 | } else { |
||
| 493 | $taxCondition2 = new \Darryldecode\Cart\CartCondition([ |
||
| 494 | 'name' => $name2, |
||
| 495 | 'type' => 'tax', |
||
| 496 | 'target' => 'item', |
||
| 497 | 'value' => $rate2, |
||
| 498 | ]); |
||
| 499 | } |
||
| 500 | } else { |
||
| 501 | $taxCondition1 = new \Darryldecode\Cart\CartCondition([ |
||
| 502 | 'name' => $name1, |
||
| 503 | 'type' => 'tax', |
||
| 504 | 'target' => 'item', |
||
| 505 | 'value' => $rate1, |
||
| 506 | ]); |
||
| 507 | $taxCondition2 = new \Darryldecode\Cart\CartCondition([ |
||
| 508 | 'name' => $name2, |
||
| 509 | 'type' => 'tax', |
||
| 510 | 'target' => 'item', |
||
| 511 | 'value' => $rate2, |
||
| 512 | ]); |
||
| 513 | } |
||
| 514 | $currency_attribute = $this->addCurrencyAttributes($id); |
||
| 515 | if ($compound == 1) { |
||
| 516 | return ['conditions' => [$taxCondition1, $taxCondition2], 'attributes' => ['tax' => [['name' => $name1, 'rate' => $rate1], ['name' => $name2, 'rate' => $rate2]], 'currency' => $currency_attribute]]; |
||
| 517 | } else { |
||
| 518 | return ['conditions' => $taxCondition2, 'attributes' => ['tax' => [['name' => $name2, 'rate' => $rate2]], 'currency' => $currency_attribute]]; |
||
| 519 | } |
||
| 520 | } |
||
| 521 | } |
||
| 522 | } catch (\Exception $ex) { |
||
| 523 | dd($ex); |
||
| 524 | |||
| 525 | throw new \Exception('Can not check the tax'); |
||
| 526 | } |
||
| 527 | } |
||
| 528 | |||
| 529 | public function cartRemove(Request $request) |
||
| 530 | { |
||
| 531 | $id = $request->input('id'); |
||
| 532 | Cart::remove($id); |
||
| 533 | |||
| 534 | return 'success'; |
||
| 535 | } |
||
| 536 | |||
| 537 | public function reduseQty(Request $request) |
||
| 538 | { |
||
| 539 | $id = $request->input('id'); |
||
| 540 | Cart::update($id, [ |
||
| 541 | 'quantity' => -1, // so if the current product has a quantity of 4, it will subtract 1 and will result to 3 |
||
| 542 | ]); |
||
| 543 | |||
| 544 | return 'success'; |
||
| 545 | } |
||
| 546 | |||
| 547 | public function updateQty(Request $request) |
||
| 548 | { |
||
| 549 | $id = $request->input('productid'); |
||
| 550 | $qty = $request->input('qty'); |
||
| 551 | Cart::update($id, [ |
||
| 552 | 'quantity' => [ |
||
| 553 | 'relative' => false, |
||
| 554 | 'value' => $qty, |
||
| 555 | ], |
||
| 556 | ]); |
||
| 557 | |||
| 558 | return 'success'; |
||
| 559 | } |
||
| 560 | |||
| 561 | public function addAddons($id) |
||
| 562 | { |
||
| 563 | $addon = $this->addons->where('id', $id)->first(); |
||
| 564 | $isTaxApply = $addon->tax_addon; |
||
| 565 | $taxConditions = $this->CheckTax($isTaxApply); |
||
| 566 | $items = ['id' => 'addon'.$addon->id, 'name' => $addon->name, 'price' => $addon->selling_price, 'quantity' => 1]; |
||
| 567 | $items = array_merge($items, $taxConditions); |
||
| 568 | |||
| 569 | return $items; |
||
| 570 | } |
||
| 571 | |||
| 572 | public function getProductAddons($productId) |
||
| 573 | { |
||
| 574 | $addons = []; |
||
| 575 | if ($this->addonRelation->where('product_id', $productId)->count() > 0) { |
||
| 576 | $addid = $this->addonRelation->where('product_id', $productId)->pluck('addon_id')->toArray(); |
||
| 577 | $addons = $this->addons->whereIn('id', $addid)->get(); |
||
| 578 | } |
||
| 579 | |||
| 580 | return $addons; |
||
| 581 | } |
||
| 582 | |||
| 583 | |||
| 584 | |||
| 585 | /** |
||
| 586 | * @return type |
||
| 587 | */ |
||
| 588 | public function clearCart() |
||
| 589 | { |
||
| 590 | foreach (Cart::getContent() as $item) { |
||
| 591 | if (\Session::has('domain'.$item->id)) { |
||
| 592 | \Session::forget('domain'.$item->id); |
||
| 593 | } |
||
| 594 | } |
||
| 595 | $this->removePlanSession(); |
||
| 596 | $renew_control = new \App\Http\Controllers\Order\RenewController(); |
||
| 597 | $renew_control->removeSession(); |
||
| 598 | Cart::clear(); |
||
| 599 | |||
| 600 | return redirect('show/cart'); |
||
| 601 | } |
||
| 602 | |||
| 603 | /** |
||
| 604 | * @param type $id |
||
| 605 | * |
||
| 606 | * @throws \Exception |
||
| 607 | * |
||
| 608 | * @return type |
||
| 609 | */ |
||
| 610 | public function licenceCart($id) |
||
| 611 | { |
||
| 612 | try { |
||
| 613 | $licence = $this->licence->where('id', $id)->first(); |
||
| 614 | $isTaxApply = 0; |
||
| 615 | $taxConditions = $this->CheckTax($isTaxApply); |
||
| 616 | $items = ['id' => $licence->id, 'name' => $licence->name, 'price' => $licence->price, 'quantity' => 1, 'attributes' => ['number_of_sla' => $licence->number_of_sla]]; |
||
| 617 | $items = array_merge($items, $taxConditions); |
||
| 618 | Cart::clear(); |
||
| 619 | Cart::add($items); |
||
| 620 | |||
| 621 | return view('themes.default1.front.cart', compact('cartCollection')); |
||
| 622 | } catch (\Exception $ex) { |
||
| 623 | dd($ex); |
||
| 624 | |||
| 625 | throw new \Exception('Problem while adding licence to cart'); |
||
| 626 | } |
||
| 627 | } |
||
| 628 | |||
| 629 | /** |
||
| 630 | * @param type $id |
||
| 631 | * @param type $key |
||
| 632 | * @param type $value |
||
| 633 | */ |
||
| 634 | public function cartUpdate($id, $key, $value) |
||
| 635 | { |
||
| 636 | try { |
||
| 637 | Cart::update( |
||
| 638 | $id, [ |
||
| 639 | $key => $value, // new item name |
||
| 640 | ] |
||
| 641 | ); |
||
| 642 | } catch (\Exception $ex) { |
||
| 643 | } |
||
| 644 | } |
||
| 645 | |||
| 646 | /** |
||
| 647 | * @param type $id |
||
| 648 | * |
||
| 649 | * @return array |
||
| 650 | */ |
||
| 651 | public function addCurrencyAttributes($id) |
||
| 652 | { |
||
| 653 | try { |
||
| 654 | $currency = $this->currency(); |
||
| 655 | $product = $this->product->where('id', $id)->first(); |
||
| 656 | if ($product) { |
||
| 657 | $productCurrency = $this->currency(); |
||
| 658 | $currency = $this->currency->where('code', $productCurrency)->get()->toArray(); |
||
| 659 | } else { |
||
| 660 | $currency = []; |
||
| 661 | } |
||
| 662 | |||
| 663 | return $currency; |
||
| 664 | } catch (\Exception $ex) { |
||
| 665 | } |
||
| 666 | } |
||
| 667 | |||
| 668 | /** |
||
| 669 | * @return type |
||
| 670 | */ |
||
| 671 | public function addCouponUpdate() |
||
| 672 | { |
||
| 673 | try { |
||
| 674 | $code = \Input::get('coupon'); |
||
| 675 | $cart = Cart::getContent(); |
||
| 676 | foreach ($cart as $item) { |
||
| 677 | $id = $item->id; |
||
| 678 | } |
||
| 679 | $promo_controller = new \App\Http\Controllers\Payment\PromotionController(); |
||
| 680 | $result = $promo_controller->checkCode($code, $id); |
||
|
1 ignored issue
–
show
|
|||
| 681 | if ($result == 'success') { |
||
| 682 | return redirect()->back()->with('success', \Lang::get('message.updated-successfully')); |
||
| 683 | } |
||
| 684 | |||
| 685 | return redirect()->back(); |
||
| 686 | } catch (\Exception $ex) { |
||
| 687 | dd($ex); |
||
| 688 | |||
| 689 | return redirect()->back()->with('fails', $ex->getMessage()); |
||
| 690 | } |
||
| 691 | } |
||
| 692 | |||
| 693 | /** |
||
| 694 | * @param type $tax_class_id |
||
| 695 | * |
||
| 696 | * @throws \Exception |
||
| 697 | * |
||
| 698 | * @return type |
||
| 699 | */ |
||
| 700 | public function getTaxByPriority($taxClassId) |
||
| 710 | } |
||
| 711 | } |
||
| 712 | |||
| 713 | /** |
||
| 714 | * @param type $price |
||
| 715 | * |
||
| 716 | * @throws \Exception |
||
| 717 | * |
||
| 718 | * @return type |
||
| 719 | */ |
||
| 720 | public static function rounding($price) |
||
| 721 | { |
||
| 722 | try { |
||
| 723 | $tax_rule = new \App\Model\Payment\TaxOption(); |
||
| 724 | $rule = $tax_rule->findOrFail(1); |
||
| 725 | $rounding = $rule->rounding; |
||
| 726 | if ($rounding == 1) { |
||
| 727 | // $price = str_replace(',', '', $price); |
||
| 728 | |||
| 729 | return round($price); |
||
| 730 | } else { |
||
| 731 | return $price; |
||
| 732 | } |
||
| 733 | } catch (\Exception $ex) { |
||
| 734 | dd($ex); |
||
| 735 | Bugsnag::notifyException($ex); |
||
| 736 | // throw new \Exception('error in get tax priority'); |
||
| 737 | } |
||
| 738 | } |
||
| 739 | |||
| 740 | /** |
||
| 741 | * @return type |
||
| 742 | */ |
||
| 743 | public function contactUs() |
||
| 744 | { |
||
| 745 | try { |
||
| 746 | return view('themes.default1.front.contact'); |
||
| 747 | } catch (\Exception $ex) { |
||
| 748 | return redirect()->back()->with('fails', $ex->getMessage()); |
||
| 749 | } |
||
| 750 | } |
||
| 751 | |||
| 752 | /** |
||
| 753 | * @param Request $request |
||
| 754 | * |
||
| 755 | * @return type |
||
| 756 | */ |
||
| 757 | public function postContactUs(Request $request) |
||
| 758 | { |
||
| 759 | $this->validate($request, [ |
||
| 760 | 'name' => 'required', |
||
| 761 | 'email' => 'required|email', |
||
| 762 | 'message' => 'required', |
||
| 763 | ]); |
||
| 764 | |||
| 765 | $set = new \App\Model\Common\Setting(); |
||
| 766 | $set = $set->findOrFail(1); |
||
| 767 | |||
| 768 | try { |
||
| 769 | $from = $set->email; |
||
| 770 | $fromname = $set->company; |
||
| 771 | $toname = ''; |
||
| 772 | $to = '[email protected]'; |
||
| 773 | $data = ''; |
||
| 774 | $data .= 'Name: '.$request->input('name').'<br/s>'; |
||
| 775 | $data .= 'Email: '.$request->input('email').'<br/>'; |
||
| 776 | $data .= 'Message: '.$request->input('message').'<br/>'; |
||
| 777 | $data .= 'Mobile: '.$request->input('Mobile').'<br/>'; |
||
| 778 | |||
| 779 | $subject = 'Faveo billing enquiry'; |
||
| 780 | $this->templateController->Mailing($from, $to, $data, $subject, [], $fromname, $toname); |
||
| 781 | //$this->templateController->Mailing($from, $to, $data, $subject); |
||
| 782 | return redirect()->back()->with('success', 'Your message was sent successfully. Thanks.'); |
||
| 783 | } catch (\Exception $ex) { |
||
| 784 | return redirect()->back()->with('fails', $ex->getMessage()); |
||
| 785 | } |
||
| 786 | } |
||
| 787 | |||
| 788 | /** |
||
| 789 | * @param type $slug |
||
| 790 | * |
||
| 791 | * @return type |
||
| 792 | */ |
||
| 793 | public function addCartBySlug($slug) |
||
| 794 | { |
||
| 795 | try { |
||
| 796 | $sub = ''; |
||
| 797 | if ($slug == 'helpdesk-with-kb-pro-edition') { |
||
| 798 | $id = 8; |
||
| 799 | $sub = 13; |
||
| 800 | } |
||
| 801 | if ($slug == 'helpdesk-and-kb-community') { |
||
| 802 | $id = 7; |
||
| 803 | } |
||
| 804 | $url = url("pricing?id=$id&subscription=$sub"); |
||
| 805 | |||
| 806 | return \Redirect::to($url); |
||
| 807 | } catch (\Exception $ex) { |
||
| 808 | return redirect()->back()->with('fails', $ex->getMessage()); |
||
| 809 | } |
||
| 810 | } |
||
| 811 | |||
| 812 | |||
| 813 | |||
| 814 | /** |
||
| 815 | * @param type $code |
||
| 816 | * |
||
| 817 | * @throws \Exception |
||
| 818 | * |
||
| 819 | * @return type |
||
| 820 | */ |
||
| 821 | public static function getCountryByCode($code) |
||
| 822 | { |
||
| 823 | try { |
||
| 824 | $country = \App\Model\Common\Country::where('country_code_char2', $code)->first(); |
||
| 825 | if ($country) { |
||
| 826 | return $country->country_name; |
||
| 827 | } |
||
| 828 | } catch (\Exception $ex) { |
||
| 829 | throw new \Exception($ex->getMessage()); |
||
| 830 | } |
||
| 831 | } |
||
| 832 | |||
| 833 | |||
| 834 | |||
| 835 | /** |
||
| 836 | * @param type $name |
||
| 837 | * |
||
| 838 | * @throws \Exception |
||
| 839 | * |
||
| 840 | * @return string |
||
| 841 | */ |
||
| 842 | public static function getTimezoneByName($name) |
||
| 843 | { |
||
| 844 | try { |
||
| 845 | if ($name) { |
||
| 846 | $timezone = \App\Model\Common\Timezone::where('name', $name)->first(); |
||
| 847 | if ($timezone) { |
||
| 848 | $timezone = $timezone->id; |
||
| 849 | } else { |
||
| 850 | $timezone = '114'; |
||
| 851 | } |
||
| 852 | } else { |
||
| 853 | $timezone = '114'; |
||
| 854 | } |
||
| 855 | |||
| 856 | return $timezone; |
||
| 857 | } catch (\Exception $ex) { |
||
| 858 | throw new \Exception($ex->getMessage()); |
||
| 859 | } |
||
| 860 | } |
||
| 861 | |||
| 862 | /** |
||
| 863 | * @param type $code |
||
| 864 | * |
||
| 865 | * @throws \Exception |
||
| 866 | * |
||
| 867 | * @return type |
||
| 868 | */ |
||
| 869 | public static function getStateByCode($code) |
||
| 870 | { |
||
| 871 | try { |
||
| 872 | $result = ['id' => '', 'name' => '']; |
||
| 873 | if ($code) { |
||
| 874 | $subregion = \App\Model\Common\State::where('state_subdivision_code', $code)->first(); |
||
| 875 | if ($subregion) { |
||
| 876 | $result = ['id' => $subregion->state_subdivision_code, 'name' => $subregion->state_subdivision_name]; |
||
| 877 | //return ['id' => $subregion->state_subdivision_code, 'name' => $subregion->state_subdivision_name]; |
||
| 878 | } |
||
| 879 | } |
||
| 880 | |||
| 881 | return $result; |
||
| 882 | } catch (\Exception $ex) { |
||
| 883 | throw new \Exception($ex->getMessage()); |
||
| 884 | } |
||
| 885 | } |
||
| 886 | |||
| 887 | /** |
||
| 888 | * @param type $id |
||
| 889 | * |
||
| 890 | * @throws \Exception |
||
| 891 | * |
||
| 892 | * @return type |
||
| 893 | */ |
||
| 894 | public static function getStateNameById($id) |
||
| 895 | { |
||
| 896 | try { |
||
| 897 | $name = ''; |
||
| 898 | $subregion = \App\Model\Common\State::where('state_subdivision_id', $id)->first(); |
||
| 899 | if ($subregion) { |
||
| 900 | $name = $subregion->state_subdivision_name; |
||
| 901 | } |
||
| 902 | |||
| 903 | return $name; |
||
| 904 | } catch (\Exception $ex) { |
||
| 905 | throw new \Exception($ex->getMessage()); |
||
| 906 | } |
||
| 907 | } |
||
| 908 | |||
| 909 | /** |
||
| 910 | * @param type $productid |
||
| 911 | * @param type $price |
||
| 912 | * @param type $cart |
||
| 913 | * @param type $cart1 |
||
| 914 | * @param type $shop |
||
| 915 | * |
||
| 916 | * @return type |
||
| 917 | */ |
||
| 918 | public static function calculateTax($productid, $price, $cart = 1, $cart1 = 0, $shop = 0) |
||
| 919 | { |
||
| 920 | try { |
||
| 921 | $template_controller = new TemplateController(); |
||
| 922 | $result = $template_controller->checkTax($productid, $price, $cart, $cart1, $shop); |
||
| 923 | |||
| 924 | $result = self::rounding($result); |
||
| 925 | |||
| 926 | return $result; |
||
| 927 | } catch (\Exception $ex) { |
||
| 928 | return redirect()->back()->with('fails', $ex->getMessage()); |
||
| 929 | } |
||
| 930 | } |
||
| 931 | |||
| 932 | /** |
||
| 933 | * @param type $rate |
||
| 934 | * @param type $price |
||
| 935 | * |
||
| 936 | * @return type |
||
| 937 | */ |
||
| 938 | public static function taxValue($rate, $price) |
||
| 939 | { |
||
| 940 | try { |
||
| 941 | $tax = $price * ($rate / 100); |
||
| 942 | $result = $tax; |
||
| 943 | |||
| 944 | $result = self::rounding($result); |
||
| 945 | |||
| 946 | return $result; |
||
| 947 | } catch (\Exception $ex) { |
||
| 948 | return redirect()->back()->with('fails', $ex->getMessage()); |
||
| 949 | } |
||
| 950 | } |
||
| 951 | |||
| 952 | /** |
||
| 953 | * @return type |
||
| 954 | */ |
||
| 955 | public static function addons() |
||
| 956 | { |
||
| 957 | try { |
||
| 958 | $items = Cart::getContent(); |
||
| 959 | $cart_productids = []; |
||
| 960 | if (count($items) > 0) { |
||
| 961 | foreach ($items as $key => $item) { |
||
| 962 | $cart_productids[] = $key; |
||
| 963 | } |
||
| 964 | } |
||
| 965 | $_this = new self(); |
||
| 966 | $products = $_this->products($cart_productids); |
||
| 967 | |||
| 968 | return $products; |
||
| 969 | } catch (\Exception $ex) { |
||
| 970 | return redirect()->back()->with('fails', $ex->getMessage()); |
||
| 971 | } |
||
| 972 | } |
||
| 973 | |||
| 974 | /** |
||
| 975 | * @param type $ids |
||
| 976 | * |
||
| 977 | * @throws \Exception |
||
| 978 | * |
||
| 979 | * @return type |
||
| 980 | */ |
||
| 981 | public function products($ids) |
||
| 982 | { |
||
| 983 | $parents_string = []; |
||
| 984 | $parent = []; |
||
| 985 | $productid = []; |
||
| 986 | |||
| 987 | try { |
||
| 988 | $parents = $this->product |
||
| 989 | ->whereNotNull('parent') |
||
| 990 | ->where('parent', '!=', 0) |
||
| 991 | ->where('category', 'addon') |
||
| 992 | ->pluck('parent', 'id') |
||
| 993 | ->toArray(); |
||
| 994 | foreach ($parents as $key => $parent) { |
||
| 995 | if (is_array($parent)) { |
||
| 996 | $parent = implode(',', $parent); |
||
| 997 | } |
||
| 998 | $parents_string[$key] = $parent; |
||
| 999 | } |
||
| 1000 | if (count($parents_string) > 0) { |
||
| 1001 | foreach ($parents_string as $key => $value) { |
||
| 1002 | if (strpos($value, ',') !== false) { |
||
| 1003 | $value = explode(',', $value); |
||
| 1004 | } |
||
| 1005 | $parent[$key] = $value; |
||
| 1006 | } |
||
| 1007 | } |
||
| 1008 | |||
| 1009 | foreach ($parent as $key => $id) { |
||
| 1010 | if (in_array($id, $ids)) { |
||
| 1011 | $productid[] = $key; |
||
| 1012 | } |
||
| 1013 | if (is_array($id)) { |
||
| 1014 | foreach ($id as $i) { |
||
| 1015 | if (in_array($i, $ids)) { |
||
| 1016 | $productid[] = $key; |
||
| 1017 | } |
||
| 1018 | } |
||
| 1019 | } |
||
| 1020 | } |
||
| 1021 | $parent_products = $this->getProductById($productid); |
||
| 1022 | |||
| 1023 | return $parent_products; |
||
| 1024 | } catch (\Exception $ex) { |
||
| 1025 | Bugsnag::notifyException($ex); |
||
| 1026 | |||
| 1027 | throw new \Exception($ex->getMessage()); |
||
| 1028 | } |
||
| 1029 | } |
||
| 1030 | |||
| 1031 | /** |
||
| 1032 | * @param type $ids |
||
| 1033 | * |
||
| 1034 | * @throws \Exception |
||
| 1035 | * |
||
| 1036 | * @return type |
||
| 1037 | */ |
||
| 1038 | public function getProductById($ids) |
||
| 1039 | { |
||
| 1040 | try { |
||
| 1041 | $products = []; |
||
| 1042 | if (count($ids) > 0) { |
||
| 1043 | $products = $this->product |
||
| 1044 | ->whereIn('id', $ids) |
||
| 1045 | ->get(); |
||
| 1046 | } |
||
| 1047 | |||
| 1048 | return $products; |
||
| 1049 | } catch (\Exception $ex) { |
||
| 1050 | dd($ex); |
||
| 1051 | |||
| 1052 | throw new \Exception($ex->getMessage()); |
||
| 1053 | } |
||
| 1054 | } |
||
| 1055 | |||
| 1056 | /** |
||
| 1057 | * @param type $iso |
||
| 1058 | * |
||
| 1059 | * @throws \Exception |
||
| 1060 | * |
||
| 1061 | * @return type |
||
| 1062 | */ |
||
| 1063 | public static function getMobileCodeByIso($iso) |
||
| 1064 | { |
||
| 1065 | try { |
||
| 1066 | $code = ''; |
||
| 1067 | if ($iso != '') { |
||
| 1068 | $mobile = \DB::table('mobile')->where('iso', $iso)->first(); |
||
| 1069 | if ($mobile) { |
||
| 1070 | $code = $mobile->phonecode; |
||
| 1071 | } |
||
| 1072 | } |
||
| 1073 | |||
| 1074 | return $code; |
||
| 1075 | } catch (\Exception $ex) { |
||
| 1076 | throw new \Exception($ex->getMessage()); |
||
| 1077 | } |
||
| 1078 | } |
||
| 1079 | |||
| 1080 | /** |
||
| 1081 | * @param type $userid |
||
| 1082 | * |
||
| 1083 | * @throws \Exception |
||
| 1084 | * |
||
| 1085 | * @return string |
||
| 1086 | */ |
||
| 1087 | public function currency($userid = '') |
||
| 1088 | { |
||
| 1089 | try { |
||
| 1090 | $currency = 'INR'; |
||
| 1091 | if ($this->checkCurrencySession() == true) { |
||
| 1092 | $currency = Session::get('currency'); |
||
| 1093 | } |
||
| 1094 | |||
| 1095 | if (\Auth::user()) { |
||
| 1096 | $currency = \Auth::user()->currency; |
||
| 1097 | if ($currency == 'USD' || $currency == '1') { |
||
| 1098 | $currency = 'USD'; |
||
| 1099 | } |
||
| 1100 | } |
||
| 1101 | if ($userid != '') { |
||
| 1102 | $user = new \App\User(); |
||
| 1103 | $currency = $user->find($userid)->currency; |
||
| 1104 | if ($currency == 'USD' || $currency == '1') { |
||
| 1105 | $currency = 'USD'; |
||
| 1106 | } else { |
||
| 1107 | $currency = 'INR'; |
||
| 1108 | } |
||
| 1109 | } |
||
| 1110 | // dd($currency); |
||
| 1111 | return $currency; |
||
| 1112 | } catch (\Exception $ex) { |
||
| 1113 | throw new \Exception($ex->getMessage()); |
||
| 1114 | } |
||
| 1115 | } |
||
| 1116 | |||
| 1117 | /** |
||
| 1118 | * @param type $productid |
||
| 1119 | * @param type $userid |
||
| 1120 | * @param type $planid |
||
| 1121 | * |
||
| 1122 | * @return type |
||
| 1123 | */ |
||
| 1124 | public function cost($productid, $userid = '', $planid = '') |
||
| 1125 | { |
||
| 1126 | try { |
||
| 1127 | $cost = $this->planCost($productid, $userid, $planid); |
||
| 1128 | if ($cost == 0) { |
||
| 1129 | $cost = $this->productCost($productid, $userid); |
||
| 1130 | } |
||
| 1131 | |||
| 1132 | return self::rounding($cost); |
||
| 1133 | } catch (\Exception $ex) { |
||
| 1134 | // throw new \Exception($ex->getMessage()); |
||
| 1135 | } |
||
| 1136 | } |
||
| 1137 | |||
| 1138 | /** |
||
| 1139 | * @param type $productid |
||
| 1140 | * @param type $userid |
||
| 1141 | * |
||
| 1142 | * @throws \Exception |
||
| 1143 | * |
||
| 1144 | * @return type |
||
| 1145 | */ |
||
| 1146 | public function productCost($productid, $userid = '') |
||
| 1147 | { |
||
| 1148 | try { |
||
| 1149 | $sales = 0; |
||
| 1150 | $currency = $this->currency($userid); |
||
| 1151 | $product = $this->product->find($productid); |
||
| 1152 | $price = $product->price()->where('currency', $currency)->first(); |
||
| 1153 | if ($price) { |
||
| 1154 | $sales = $price->sales_price; |
||
| 1155 | if ($sales == 0) { |
||
| 1156 | $sales = $price->price; |
||
| 1157 | } |
||
| 1158 | } |
||
| 1159 | //} |
||
| 1160 | |||
| 1161 | return $sales; |
||
| 1162 | } catch (\Exception $ex) { |
||
| 1163 | throw new \Exception($ex->getMessage()); |
||
| 1164 | } |
||
| 1165 | } |
||
| 1166 | |||
| 1167 | /** |
||
| 1168 | * @param type $productid |
||
| 1169 | * @param type $userid |
||
| 1170 | * @param type $planid |
||
| 1171 | * |
||
| 1172 | * @throws \Exception |
||
| 1173 | * |
||
| 1174 | * @return type |
||
| 1175 | */ |
||
| 1176 | public function planCost($productid, $userid, $planid = '') |
||
| 1204 | } |
||
| 1205 | } |
||
| 1206 | |||
| 1207 | /** |
||
| 1208 | * @throws \Exception |
||
| 1209 | */ |
||
| 1210 | public function removePlanSession() |
||
| 1211 | { |
||
| 1212 | try { |
||
| 1213 | if (Session::has('plan')) { |
||
| 1214 | Session::forget('plan'); |
||
| 1215 | } |
||
| 1216 | } catch (\Exception $ex) { |
||
| 1217 | throw new \Exception($ex->getMessage()); |
||
| 1218 | } |
||
| 1219 | } |
||
| 1220 | |||
| 1221 | /** |
||
| 1222 | * @throws \Exception |
||
| 1223 | * |
||
| 1224 | * @return bool |
||
| 1225 | */ |
||
| 1226 | public function checkPlanSession() |
||
| 1236 | } |
||
| 1237 | } |
||
| 1238 | |||
| 1239 | /** |
||
| 1240 | * @throws \Exception |
||
| 1241 | * |
||
| 1242 | * @return bool |
||
| 1243 | */ |
||
| 1244 | public function checkCurrencySession() |
||
| 1245 | { |
||
| 1246 | try { |
||
| 1247 | if (Session::has('currency')) { |
||
| 1248 | return true; |
||
| 1249 | } |
||
| 1250 | |||
| 1251 | return false; |
||
| 1252 | } catch (\Exception $ex) { |
||
| 1253 | throw new \Exception($ex->getMessage()); |
||
| 1254 | } |
||
| 1255 | } |
||
| 1256 | |||
| 1257 | /** |
||
| 1258 | * @param type $productid |
||
| 1259 | * |
||
| 1260 | * @throws \Exception |
||
| 1261 | * |
||
| 1262 | * @return bool |
||
| 1263 | */ |
||
| 1264 | public function allowSubscription($productid) |
||
| 1278 | } |
||
| 1279 | } |
||
| 1280 | } |
||
| 1281 |
This check looks for accesses to local static members using the fully qualified name instead of
self::.While this is perfectly valid, the fully qualified name of
Certificate::TRIPLEDES_CBCcould just as well be replaced byself::TRIPLEDES_CBC. Referencing local members withself::assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.