0

I have a problem with Laravel notifications. I try to give a user notification about something, but Laravel cannot find notification class.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Auth;    

class NotificationController extends Controller
{    

    public function getNot(Request $request)
    {
        $user = Auth::user();            

        $user->notify(new NewPost('a'));
    }
}

I've also created a notification with the name NewPost.php, the problem is:

Class 'App\Http\Controllers\NewPost' not found

this one, so in the User model already included Notifications and notifiable.

2
  • Please, add your notification code and the model code related to the notification. Commented Mar 17, 2019 at 20:48
  • Well in my User model ther is only use Notifable; Commented Mar 17, 2019 at 20:51

1 Answer 1

1

Add use statement before class definition.

use Illuminate\Http\Request;
use Auth; 
use App\Notifications\NewPost;

I assume that you create notification by artisan, if no, then keep in mind that namespace could be different.

Sign up to request clarification or add additional context in comments.

4 Comments

i created it by artisan
stilll i've got the error Class 'App\Notification\NewPost' not found
Notifications not Notification
Yeah, this is just a namespace issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.