Create Dynamic Navigation in Laravel

Brijpal Sharma
laravel   Publish on:-March 27th, 2019 , Category:- Web Development

In this blog post, we learn how to make the dynamic navigation bar in Laravel 5. we fetch data from the database and show into the navigation bar.

Many projects need dynamic nav bar where the user needs dynamic data in the navigation bar when any new data, should be shown in the navigation bar. so in this blog post, we learn how to create dynamic navigation in Laravel

Step:1 Create a  new Laravel Application.

laravel new navigation

After successful install Laravel Application, we move to the next step.

Step:2 Create some data table and insert database.

We required some data to show on navigation bar so insert dummy data.

Step:3 Add some code in AppServiceProvider.php 

Create Dynamic Navigation in Laravel

Here we call some data using model and pass into all view so we can print that data in the whole project view.


namespace App\Providers;
use App\User;
use View;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
    public function register()

    public function boot()
        View::composer('*', function($view)
            $allUser= User::all();
            $view->with('allUser', $allUser);


Here we use the User table to show all user record in the navigation bar.

Step:4 Show in View File

this is an easy part where we show data in the blade page.

   @foreach ($allUser as $item)
         <p>{{$item->name}} </p>

So here we completed the tutorial on how to create dynamic navigation in Laravel.

Thank you...


Brijpal Sharma

Hello, My Name is Brijpal Sharma. I am a Web Developer, Professional Blogger and Digital Marketer from India. I am the founder of Codermen. I started this blog to help web developers & bloggers by providing easy and best tutorials, articles and offers for web developers and bloggers...


You must be logged in to post a comment.