diff --git a/app/Helpers/activeHelpers.php b/app/Helpers/activeHelpers.php index 1da8e615..b6df362e 100644 --- a/app/Helpers/activeHelpers.php +++ b/app/Helpers/activeHelpers.php @@ -1,4 +1,5 @@ getAction(); } -} \ No newline at end of file +} diff --git a/app/Services/Active/Active.php b/app/Services/Active/Active.php index 6f0ed08b..fbf580a1 100644 --- a/app/Services/Active/Active.php +++ b/app/Services/Active/Active.php @@ -21,7 +21,6 @@ * @author Hieu Le * * @version 3.2.0 - * */ class Active { @@ -61,6 +60,7 @@ class Active * @var string */ protected $uri; + /** * Active constructor. * @@ -70,6 +70,7 @@ public function __construct($request) { $this->updateInstances(null, $request); } + /** * Update the route and request instances. * @@ -90,6 +91,7 @@ public function updateInstances($route, $request) $this->method = last($actionSegments); } } + /** * Get the active class if the condition is not falsy. * @@ -103,6 +105,7 @@ public function getClassIf($condition, $activeClass = 'active', $inactiveClass = { return $condition ? $activeClass : $inactiveClass; } + /** * Check if the URI of the current request matches one of the specific URIs. * @@ -115,13 +118,15 @@ public function checkUri($uris) if (!$this->request) { return false; } - foreach ((array)$uris as $uri) { + foreach ((array) $uris as $uri) { if ($this->uri == $uri) { return true; } } + return false; } + /** * Check if the current URI matches one of specific patterns (using `Str::is`). * @@ -171,8 +176,10 @@ public function checkQuery($key, $value) ) { return true; } + return false; } + /** * Check if the name of the current route matches one of specific values. * @@ -189,8 +196,10 @@ public function checkRoute($routeNames) if (in_array($routeName, (array) $routeNames)) { return true; } + return false; } + /** * Check the current route name with one or some patterns. * @@ -212,8 +221,10 @@ public function checkRoutePattern($patterns) return true; } } + return false; } + /** * Check if the parameter of the current route has the correct value. * @@ -233,8 +244,10 @@ public function checkRouteParam($param, $value) if (is_a($paramValue, Model::class)) { return $paramValue->{$paramValue->getKeyName()} == $value; } + return $paramValue == $value; } + /** * Return 'active' class if current route action match one of provided action names. * @@ -247,11 +260,13 @@ public function checkAction($actions) if (!$this->action) { return false; } - if (in_array($this->action, (array)$actions)) { + if (in_array($this->action, (array) $actions)) { return true; } + return false; } + /** * Check if the current controller class matches one of specific values. * @@ -264,11 +279,13 @@ public function checkController($controllers) if (!$this->controller) { return false; } - if (in_array($this->controller, (array)$controllers)) { + if (in_array($this->controller, (array) $controllers)) { return true; } + return false; } + /** * Get the current controller method. * @@ -278,6 +295,7 @@ public function getMethod() { return $this->method ?: ''; } + /** * Get the current action string. * @@ -287,6 +305,7 @@ public function getAction() { return $this->action ?: ''; } + /** * Get the current controller class. * @@ -296,4 +315,4 @@ public function getController() { return $this->controller ?: ''; } -} \ No newline at end of file +}