@@ -56,6 +56,15 @@ public function registerRoutes()
5656 }
5757 }
5858
59+ public function registerAdminRoutes ()
60+ {
61+ if (config ('cms.should_translate ' )) {
62+ $ this ->registerTranslatableAdminRoutes ();
63+ } else {
64+ $ this ->registerNormalAdminRoutes ();
65+ }
66+ }
67+
5968 public function registerNormalRoutes (): void
6069 {
6170 $ root_slugs = app (RootSlugsRegistrar::class)->getSlugs ();
@@ -76,7 +85,7 @@ public function registerNormalRoutes(): void
7685 }
7786 }
7887
79- public function registerAdminRoutes (): void
88+ public function registerNormalAdminRoutes (): void
8089 {
8190 /**
8291 * Categories
@@ -136,36 +145,41 @@ public function registerTranslatableAdminRoutes()
136145 Route::group ([
137146 'prefix ' => '{language} ' ,
138147 ], function () {
139- $ this ->registerAdminRoutes ();
148+ $ this ->registerNormalAdminRoutes ();
140149 });
141150 }
142151
143- public function addToSidebar (array $ menus = [])
152+ public function adminMenuItems (array $ menus = [])
144153 {
145154 $ all_post_types = PostType::all ();
146155
147156 foreach ($ all_post_types as $ post_type ) {
148157 $ name = Str::title ($ post_type ->name );
149158 $ children = [
150159 MenuItem::make ($ name )
160+ ->controller (PostsController::class)
151161 ->can ('view_ ' . $ post_type ->permission_slug )
152162 ->active (optional (request ()->route ('post_type ' ))->slug == $ post_type ->slug )
153- ->url (config ('cms.should_translate ' )
154- ? translate_route ('admin.posts.index ' , $ post_type ->slug )
155- : route ('admin.posts.index ' , $ post_type ->slug )
156- )
163+ // ->url(config('cms.should_translate')
164+ // ? translate_route('admin.posts.index', $post_type->slug)
165+ // : route('admin.posts.index', $post_type->slug)
166+ // )
167+ ->url (translate_route ('admin.posts.index ' , $ post_type ->slug ))
157168 ->icon ('zmdi- ' . $ post_type ->icon )
158169 ->count (Post::query ()->userVisibleForPostType ($ post_type )->postType ($ post_type ->slug )->pending ()),
159170 ];
160171
161172 if ($ post_type ->hasFeature (PostTypeFeatures::CATEGORIES )) {
162173 $ children [] = MenuItem::make (_d (':name Categories ' , ['name ' => Str::singular ($ name )]))
174+ ->controller (CategoriesController::class)
163175 ->can ('view_ ' . Str::singular ($ post_type ->permission_slug ) . '_categories ' )
164- ->url (config ('cms.should_translate ' )
165- ? translate_route ('admin.categories.index ' , Str::singular ($ post_type ->slug ) . '-categories ' )
166- : route ('admin.categories.index ' , Str::singular ($ post_type ->slug ) . '-categories ' )
167- )
168- ->active (optional (request ()->route ('category_type ' ))->slug == Str::singular ($ post_type ->slug ) . '-categories ' );
176+ // ->active(optional(request()->route('category_type'))->slug == Str::singular($post_type->slug) . '-categories')
177+ // ->url(config('cms.should_translate')
178+ // ? translate_route('admin.categories.index', Str::singular($post_type->slug) . '-categories')
179+ // : route('admin.categories.index', Str::singular($post_type->slug) . '-categories')
180+ // )
181+ ->url (translate_route ('admin.categories.index ' , Str::singular ($ post_type ->slug ) . '-categories ' ))
182+ ;
169183
170184 $ menus [] =
171185 MenuItem::make ($ name )
0 commit comments