# Admin Menu
# Directory Structure
To ensure that the admin menu includes the necessary configuration, follow these steps:
In your package's source directory, which is typically located at
packages/Webkul/Blog/src
, create a new folder namedConfig
if it doesn't already exist.└── packages └── Webkul └── Blog └── src ├── ... └── Config └── admin-menu.php
Inside the newly created
Config
folder, create a file namedadmin-menu.php
.Copy and paste the following code into the
admin-menu.php
file:<?php return [ [ 'key' => 'blogs', 'name' => 'Blogs', 'route' => 'blog.admin.index', 'sort' => 2, 'icon-class' => 'blog-icon', ], ];
In your
admin-routes.php
file (located in the same package's source directory), add the named routeblog.admin.index
as follows:Route::get('/blog', [PostController::class, 'index'])->name('blog.admin.index');
In this step, we define the route that corresponds to the menu item added in the previous step.
# Add Menu Icon
To add the menu icon styling, open the
assets/scss/admin.scss
file within your package and add the following code:.blog-icon { background-image: url("../images/blog.png"); width: 45px; height: 45px; opacity: 0.6; margin-left: 4px !important; } .active { .blog-icon { opacity: 1; background-image: url("../images/blog-active.png"); } }
Ensure that you have the necessary
.png
image files (blog.png
andblog-active.png
) and manually place them inside theassets/images
folder of your package.To merge the
admin-menu.php
configuration with the core menu file, use themergeConfigFrom()
method in theregister()
method of your package's service provider. Here's an example:<?php namespace Webkul\Blog\Providers; use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { /** * Register services. * * @return void */ public function register() { $this->mergeConfigFrom( dirname(__DIR__) . '/Config/admin-menu.php', 'menu.admin' ); } }
Finally, run the following command to optimize your application:
php artisan optimize
After completing these steps, the menu item should appear in the admin panel.
Admin Menu Output
← Assets Homepage Menu →