Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

azim1728's avatar

Creating Custom Cards not working.

Hey there,

I am using Nova 4 and Laravel 10.

I have requirement to greet user on logging in with a Welcome Message on the Dashboard. For that I am trying custom card but after creating a card when I call it in dashboard it keeps saying Class not found and redirect me to 404. I double checked the class and it is already present in the dashboard file. I don't know what causing the error.

Please if anyone can help me out with this.

Thanks in advance.

0 likes
3 replies
azim1728's avatar

This is my code Main.php

<?php

namespace App\Nova\Dashboards;

use Acme\WelcomeCard\WelcomeCard;
use Laravel\Nova\Dashboards\Main as Dashboard;


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

nova-components/WelcomeCard/src/WelcomeCard.php

<?php

namespace Pt1App\WelcomeCard;

use Laravel\Nova\Card;

class WelcomeCard extends Card
{
    /**
     * The width of the card (1/3, 1/2, or full).
     *
     * @var string
     */
    public $width = '1/3';

    /**
     * Get the component name for the element.
     *
     * @return string
     */
    public function component()
    {
        return view('welcome-card', [
            'title' => 'Welcome to Laravel Nova',
            'message' => 'Thank you for using Laravel Nova!',
        ]);
    }
}

Providers/NovaServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Laravel\Nova\Nova;
use Laravel\Nova\NovaApplicationServiceProvider;
use App\Nova\WelcomeScreen;
use Pt1App\WelcomeCard\WelcomeCard;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();

        Nova::cards([
            WelcomeCard::make()
        ]);

    }

    /**
     * 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, [
                //
            ]);
        });
    }

    /**
     * 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()
    {
        //
    }

}

Error

Class Pt1App\WelcomeCard\WelcomeCard not found.

Please check and let me know what I am missing here.

azim1728's avatar
azim1728
OP
Best Answer
Level 1

I was able to fix this by updating * to @dev in the composer.json file and running

composer update

command.

1 like

Please or to participate in this conversation.