Ramazan's avatar

Call to undefined method

hello guys i got this error when i have tired to send password reset link

   BadMethodCallException
   Call to undefined method Illuminate\Database\Query\Builder::notify()
0 likes
19 replies
Ramazan's avatar

this is my model

namespace App;
  use Illuminate\Notifications\Notifiable;
   use App\Notifications\ResetPasswordNotification;
    //Class which implements Illuminate\Contracts\Auth\Authenticatable
      use Illuminate\Foundation\Auth\User as Authenticatable;
   use Illuminate\Support\Facades\Event;


class User extends Authenticatable
{
    use Notifiable;

       public function sendPasswordResetNotification($token)
    {
        $this->notify(new ResetPasswordNotification($token));
     }
 }
shez1983's avatar

by default LARAVEL takes care of it for you.. are you doing a custom thing yourself?

Ramazan's avatar

I have fixed that by using facade but when i want to go to resetpassword route from mailtrap i got this error

   Object not found!
   The requested URL was not found on this server. If you entered the URL manually 
   please check your spelling and try again.

   If you think this is a server error, please contact the webmaster.
Ramazan's avatar

this is my notification

     public function toMail($notifiable)
    {
    $notifiable->email = $this->email;
    $url = url('password/reset/{token}'.$this->token);
    return (new MailMessage)
                ->line('you receiving this email because we received a password reset from 
    your account.')
                ->action('Reset Password', $url)
                ->line('Thank you for using our application!');
     }

this is the route

  Route::get('password/reset/{token}', 'ResetPasswordController@showResetForm')- 
 >name('password.reset');
Snapey's avatar

have you set APP_URL correctly in your .env file?

Ramazan's avatar

this is my APP_URL

APP_URL=http://localhost
Ramazan's avatar

i have used notification and the link is

      public function toMail($notifiable)
  {
    $notifiable->email = $this->email;
    $url = url('password/reset/{token}'.$this->token);
    return (new MailMessage)
                ->line('you receiving this email because we received a password reset from 
      your account.')
                ->action('Reset Password', $url)
                ->line('Thank you for using our application!');
     }

i haven't used the mail so this is the only link which used by mailtrap is't it? the mailtrap link is

 http://localhost/password/reset/the token 
Snapey's avatar

This is not right

$url = url('password/reset/{token}'.$this->token);

it should be

url = url('password/reset/',$this->token);

or

url = url('password/reset/' . $this->token);

Snapey's avatar

So when do you get the error, is it when creating the email or when clicking on the link in the email.

What does the error message say about the file and line number

Ramazan's avatar

clicking link in the email the error is

Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Snapey's avatar

What is in the address bar of the browser when you see this error

Snapey's avatar

and what is in the addressbar when you request password reset

Ishatanjeeb's avatar

Set the Notifiable trait in your User mode.


Illuminate\Notifications\Notifiable

Please or to participate in this conversation.