It must be an error... it is clearly an Interface. Just remove the use trait syntax inside the model.
MustVerifyEmail - it is not a trait
A couple of days I was doing some tests with the new Laravel features and was able to set up the Email Verifications no problem, but I came to setup a new project today and for some reason it's just no longer.
I went back to the documentation to see if I had missed something and even watched the laracast video, following instructions, but it just keeps giving me the following error:
App\User cannot use Illuminate\Contracts\Auth\MustVerifyEmail - it is not a trait
The code in the documentation is as follows,
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements MustVerifyEmail
{
use MustVerifyEmail, Notifiable;
// ...
}
And the code in my User model is,
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements MustVerifyEmail
{
use MustVerifyEmail, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
I've set up a few new test laravel projects thinking it might just be a problem with the install and I've updated the laravel installer. Any ideas let me know.
Thanks a lot
Actually, the trait is pulled in by the Authenticatable (User model) class
vendor/laravel/framework/src/Illuminate/Foundation/Auth/User.php
class User extends Model implements
AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail;
}
So you should not have needed to add the trait.
I think you just confused contract and trait
Please or to participate in this conversation.