附链接:
使用artisan命令生成注册模块
php artisan make:auth
修改用户信息表 打开database/migrations/create_users_table.php 修改如下
$table->increments('id'); $table->string('name')->unique(); $table->string('email')->unique(); $table->string('password'); $table->string('confirmation_token'); $table->rememberToken(); $table->timestamps();
创建用户信息表
php artisan migrate
在App/Http/Controller/Auth/RegisterController.php中添加sendVerifyEmailTo()方法,并修改create方法,具体代码如下
``` protected function create(array $data) { $user = User::create([ 'name' => $data['name'], 'email' => $data['email'], 'confirmation_token' => str_random(40), 'password' => bcrypt($data['password']), ]); $this->sendVerifyEmailTo($user); return $user; }
private function sendVerifyEmailTo($user)
{
$data = [
'url' =>'你的网址'.$user->confirmation_token,
'name' => $user->name,
];
$template = new SendCloudTemplate('test_template_active', $data);
Mail::raw($template, function ($message) use ($user) {
$message->from('example@example.com', 'example');
$message->to($user->email);
});
}
```
use Naux\Mail\SendCloudTemplate;
use Mail;
不然会报错:
method SendCloudTemplate not found