Skip to content

Instantly share code, notes, and snippets.

@endihunter
Created February 6, 2017 13:55
Show Gist options
  • Save endihunter/aa2c4ebb9060804385a3558bbd1917c0 to your computer and use it in GitHub Desktop.
Save endihunter/aa2c4ebb9060804385a3558bbd1917c0 to your computer and use it in GitHub Desktop.
patch a navigation middleware, activate module navigation
From f0f3fe15becb32c85613728c67694b9a0bc91a82 Mon Sep 17 00:00:00 2001
From: Endi <[email protected]>
Date: Mon, 6 Feb 2017 15:52:01 +0200
Subject: [PATCH] Set default active status
---
src/Middleware/Resources.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/Middleware/Resources.php b/src/Middleware/Resources.php
index 102e985..e80cbcf 100644
--- a/src/Middleware/Resources.php
+++ b/src/Middleware/Resources.php
@@ -113,7 +113,14 @@ class Resources
$module->title(),
['module' => $module->url()],
$order,
- $module->linkAttributes()
+ array_merge(
+ $module->linkAttributes(),
+ [
+ 'active' => function () use ($module) {
+ return starts_with(\URL::getRequest()->getPathInfo(), "/admin/{$module}");
+ },
+ ]
+ )
);
} else {
$navigation->url(
--
2.9.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment