Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple independent Laravel Nova Dashboards in different routes?

Tags:

laravel-nova

I am interested if there is a way to generate multiple independent Laravel Nova dashboards within the same multi-auth application?

Eg.
Administrator Dashboard - {admin.example.com/nova/users}
Member Dashboard = {example.com/nova/home}

like image 308
Stu Avatar asked Dec 31 '25 04:12

Stu


1 Answers

You can find all info about creating additional dashboard in Laravel Nova 4 documentation

By this link

For creating new dashboard use command

php artisan nova:dashboard MemberDashboard

Then in app/Nova/Dashboards you find MemberDashboard.php file

<?php

namespace App\Nova\Dashboards;

use Laravel\Nova\Dashboard;
use Laravel\Nova\Cards\Help;

class MemberDashboard extends Dashboard
{
    /**
     * Get the cards for the dashboard.
     *
     * @return array
     */
    public function cards()
    {
        return [
            Help,
        ];
    }
}

For changing default url you can add to MemberDashboard method

/**
 * Get the URI key of the dashboard.
 *
 * @return string
 */
public function uriKey()
{
    return 'dashboard-for-member';
}

After that you must register this dashboard in App/Providers/NovaServiceProvider

use App\Nova\Dashboards\Main;
use App\Nova\Dashboards\MemberDashboard;

/**
 * Get the dashboards that should be listed in the Nova sidebar.
 *
 * @return array
 */
protected function dashboards()
{
    return [
        Main::make(),
        MemberDashboard::make()->canSee(function ($request) {
           return $request->user()->isMember();
        }),
    ];
}

For checking a role of the user you need add method isMember() to User model that will return the bool value

Similarly you can create AdministratorDashboard and define different cards in it.

like image 192
Vlad Shcherbyna Avatar answered Jan 04 '26 07:01

Vlad Shcherbyna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!