Php Laravel MustVerifyEmail未发送电子邮件

Php Laravel MustVerifyEmail未发送电子邮件,php,laravel,email-verification,laravel-5.7,Php,Laravel,Email Verification,Laravel 5.7,我目前正在与Laravel 5.7合作一个项目。由于我在我的用户模型中实现了MustVerifyEmail类,应用程序没有按预期发送电子邮件。情况是: 1) 我在这里遵循了Laravel文档: 2) 我曾经测试过这个功能,但是我没有收到来自应用程序的任何验证电子邮件 3) 我尝试使用Auth::routes()而不是Auth::routes(['verify'=>true])并预期会出现错误,但没有出现错误,应用程序在用户注册后将我重定向到主页 这是我的用户型号: <?php namesp

我目前正在与Laravel 5.7合作一个项目。由于我在我的
用户
模型中实现了
MustVerifyEmail
类,应用程序没有按预期发送电子邮件。情况是:

1) 我在这里遵循了Laravel文档:

2) 我曾经测试过这个功能,但是我没有收到来自应用程序的任何验证电子邮件

3) 我尝试使用
Auth::routes()
而不是
Auth::routes(['verify'=>true])
并预期会出现错误,但没有出现错误,应用程序在用户注册后将我重定向到主页

这是我的
用户
型号:

<?php
namespace App;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable implements MustVerifyEmail
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'first_name', 'last_name', 'email', 'password', 'phone_number', 'username', 'role'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token'
    ];

    public function freelancer()
    {
        return $this->hasOne('App\Freelancer', 'freelancer_id', 'id');
    }

    public function employer()
    {
        return $this->hasOne('App\Employer', 'employer_id', 'id');
    }
}
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Freelancer extends Model
{
    protected $table = 'freelancer';

    public $timestamps = false;

    protected $fillable = [
      'overview_description'
    ];
}
我的
自由职业者
雇主
模型:

<?php
namespace App;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable implements MustVerifyEmail
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'first_name', 'last_name', 'email', 'password', 'phone_number', 'username', 'role'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token'
    ];

    public function freelancer()
    {
        return $this->hasOne('App\Freelancer', 'freelancer_id', 'id');
    }

    public function employer()
    {
        return $this->hasOne('App\Employer', 'employer_id', 'id');
    }
}
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Freelancer extends Model
{
    protected $table = 'freelancer';

    public $timestamps = false;

    protected $fillable = [
      'overview_description'
    ];
}

您忘了在用户模型中使用
illighted\Auth\MustVerifyEmail
特性,该特性定义负责发送验证电子邮件的
sendEmailVerificationNotification
方法

use Illuminate\Contracts\Auth\MustVerifyEmail as MustVerifyEmailContract; // this is an interface
use Illuminate\Auth\MustVerifyEmail; // this the trait

class User extends Authenticatable implements MustVerifyEmail
{
    use MustVerifyEmail, Notifiable;

    // all the other code goes here

}

在我更新了
RegisterController.php
中的
create
函数后,问题得到了解决,如下所示:

  protected function create(array $data)
  {
     $user = User::create([
    'first_name' => $data['first_name'],
    'last_name' => $data['last_name'],
    'email' => $data['email'],
    'phone_number' => $data['phone_number'],
    'username' => $data['username'],
    'password' => Hash::make($data['password']),
    'role' => $data['role'],
    ]);

    return $user;
  }

至于
自由职业者
雇主
实例的创建过程,我将其放在电子邮件验证之后。

您是否配置了电子邮件?是的,当我开始一个新的laravel项目时,电子邮件工作得很好。此问题仅在此项目中出现。应用程序仍不发送任何验证电子邮件。但是,当我在verify.blade.php请求另一封电子邮件时,我能够收到该电子邮件。