Skip to content

Call to a member function authorizedToSee() on null (View: \vendor\laravel\nova\resources\views\layout.blade.php) #6568

@beshoo

Description

@beshoo
  • Laravel Version: 10.x
  • Nova Version: 4.34.3
  • PHP Version: 8.2
  • Database Driver & Version:
  • Operating System and Version: Windows

Description:

Once I add this to novaServiceProvider

 Nova::mainMenu(function (Request $request) {
            return [
                MenuSection::dashboard(User::class)->icon('chart-bar'),
            ];
        });
<?php

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Laravel\Nova\Menu\MenuSection;
use Laravel\Nova\Nova;
use Laravel\Nova\NovaApplicationServiceProvider;
use Illuminate\Http\Request;

use App\Nova\User;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();
        //Nova::enableRTL();
        Nova::initialPath('/resources/users');

        Nova::mainMenu(function (Request $request) {
            return [
                MenuSection::dashboard(User::class)->icon('chart-bar'),
            ];
        });

    }

    /**
     * Register the Nova routes.
     *
     * @return void
     */
    protected function routes()
    {
        Nova::routes()
                ->withAuthenticationRoutes()
                ->withPasswordResetRoutes()
                ->register();
    }

    /**
     * Register the Nova gate.
     *
     * This gate determines who can access Nova in non-local environments.
     *
     * @return void
     */
    protected function gate()
    {
        Gate::define('viewNova', function ($user) {
            return in_array($user->email, [
                'beshoo@gmail.com'
            ]);
        });
    }

    /**
     * Get the dashboards that should be listed in the Nova sidebar.
     *
     * @return array
     */
    protected function dashboards()
    {
        return [
            new \App\Nova\Dashboards\Main,
        ];
    }

    /**
     * Get the tools that should be listed in the Nova sidebar.
     *
     * @return array
     */
    public function tools()
    {
        return [];
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions