Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to locate a class or view for component [notify-messages]. #115

Open
loglinn05 opened this issue Apr 21, 2023 · 6 comments
Open

Unable to locate a class or view for component [notify-messages]. #115

loglinn05 opened this issue Apr 21, 2023 · 6 comments

Comments

@loglinn05
Copy link

loglinn05 commented Apr 21, 2023

Environment: Laravel 10 (with AdminLTE).
I've added the Mckenziearts\Notify\LaravelNotifyServiceProvider::class service provider to config/app.php, published the config file and assets and executed composer dump-autoload. Here is my layout:

@extends('adminlte::page')

@section('title', 'Admin')

@section('content_header')
    @yield('content_header')
@stop

@section('content')
    @include('notify::components.notify')
    @yield('main')
    <x:notify-messages />
@stop

@section('css')
    @notifyCss
    <link rel="stylesheet" href="/assets/admin.css">
@stop

@section('js')
    @notifyJs
@stop

And here I'm calling notify() in my controller:

<?php

namespace App\Http\Controllers\Product;

use App\Http\Controllers\Controller;
use App\Http\Requests\Product\StoreRequest;
use App\Models\Product;

class StoreController extends Controller
{
    /**
     * Handle the incoming request.
     */
    public function __invoke(StoreRequest $request)
    {
        // ...
        notify()->success('Laravel Notify is awesome!');
        // ...
    }
}

This is what I get:
https://flareapp.io/share/DPyrJl47#F67
Thanks in advance!

@loglinn05
Copy link
Author

I've just deleted <x:notify-messages />, and the error disappeared, but I still don't see any toast.

@rgbjay
Copy link

rgbjay commented May 2, 2023

I am having this same issue. Using <x:notify-messages/> results in

Unable to locate a class or view for component [notify-messages].

This is on Laravel 10 using v2.4. Was working fine on Laravel 8 & 9.

@loglinn05 loglinn05 reopened this May 2, 2023
@rgbjay
Copy link

rgbjay commented May 2, 2023

@loglinn05 Switching to using @include('notify::components.notify') instead seems to fix the problem.

Would indicate an issue with the implementation of Laravel Blade Components I suppose.

Hope that helps you.

@chadpriddle
Copy link

Same issue, was working well with Laravel 9 and then I did composer update and got the same error

@yuxxeun
Copy link

yuxxeun commented Jun 28, 2023

y'all can use @include('notify::components.notify') instead of <x:notify-messages/>, if y'all still want to use <x:notify-messages/> u should make component with php artisan make:component notify-messages command and put all the reuqirement to that file

@josephT273
Copy link

first i imported
@notifyCss and @notifyJs then finally imported @include('notify::components.notify') and it works

here is sample code

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.bunny.net">
    <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
    <!-- Scripts -->
    @notifyCss
    @vite(['resources/css/app.css', 'resources/js/app.js'])
</head>

<body class="font-sans antialiased">
    <div class="min-h-screen bg-gray-100">
        @include('layouts.navigation')
        @include('notify::components.notify')
        <!-- Page Heading -->
        @if (isset($header))
            <header class="bg-white shadow">
                <div class="px-4 py-6 mx-auto max-w-7xl sm:px-6 lg:px-8">
                    {{ $header }}
                </div>
            </header>
        @endif

        <!-- Page Content -->
        <main>
            {{ $slot }}
        </main>
    </div>
    @notifyJs
</body>

</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants