From 69aeb2a25477b2f93aafe720438493fdf0c67291 Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Thu, 7 Feb 2019 13:58:14 +0530 Subject: [PATCH] added a function to find the state by code and country code --- packages/Webkul/Core/src/Core.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index 9f75c789e..d82f557ef 100755 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -591,6 +591,24 @@ class Core return $collection; } + /** + * Retrieve all grouped states by country code + * + * @return Collection + */ + public function findStateByCountryCode($countryCode = null, $stateCode = null) + { + $collection = array(); + + $collection = $this->countryStateRepository->findByField(['country_code' => $countryCode, 'code' => $stateCode]); + + if(count($collection)) { + return $collection->first(); + } else { + return false; + } + } + /** * Returns time intervals *