From c88be0206dd3ff53286a77567814ec8ff2e912af Mon Sep 17 00:00:00 2001 From: Jeff Madsen Date: Tue, 11 Dec 2018 23:09:49 +0000 Subject: [PATCH 1/3] allow ordering of dashboards --- src/Dashboard.php | 2 +- src/DashboardNova.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Dashboard.php b/src/Dashboard.php index 9a664f4..ee84b78 100644 --- a/src/Dashboard.php +++ b/src/Dashboard.php @@ -6,5 +6,5 @@ abstract class Dashboard extends Element { - // + public $sort; } diff --git a/src/DashboardNova.php b/src/DashboardNova.php index a020ebb..b815fa4 100644 --- a/src/DashboardNova.php +++ b/src/DashboardNova.php @@ -78,13 +78,13 @@ public static function dashboardsIn($directory) } static::dashboards( - collect($dashboards)->sort()->transform(function ($dashboard) { + collect($dashboards)->transform(function ($dashboard) { if ($dashboard instanceof Dashboard) { return $dashboard; } return app()->make($dashboard); - })->all() + })->sortBy('order')->all() ); } From 447735a925e1607d34a60117af24efd8e8680a60 Mon Sep 17 00:00:00 2001 From: Jeff Madsen Date: Tue, 11 Dec 2018 23:19:05 +0000 Subject: [PATCH 2/3] let the world know --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6fa9237..581c0dd 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ There is now a `php artisan nova:dashboard ` command exposed via the CLI. If you run this, you'll get a `App/Nova/Dashboards` directory created, which will house your custom dashboards. +Dashboards have a `public $order` variable you can use to set the order they appear in the navbar. See the `Dashboard` class for more. + If you are another package creating a nova dashboard, you will need to register it using: ```php From 9bd8619ead6bead337a1ae222b2e52b8359adcd4 Mon Sep 17 00:00:00 2001 From: Jeff Madsen Date: Wed, 12 Dec 2018 01:40:45 +0000 Subject: [PATCH 3/3] set default ordering --- src/DashboardNova.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DashboardNova.php b/src/DashboardNova.php index b815fa4..f3011aa 100644 --- a/src/DashboardNova.php +++ b/src/DashboardNova.php @@ -84,7 +84,7 @@ public static function dashboardsIn($directory) } return app()->make($dashboard); - })->sortBy('order')->all() + })->sortBy('label')->sortBy('order')->all() ); }