我正在使用laravel,我想进行身份验证注册,并通过电子邮件和提供商进行检查。使用电子邮件和提供商,因为如果用户使用社交媒体(例如:facebook)登录时具有与用户使用电子邮件登录相同的电子邮件,则用户可以注册。我只能通过电子邮件进行检查。 这是我的注册控制器
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
public function __construct()
{
$this->middleware('guest');
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'username' => 'required|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
'provider' => 'unique:users',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
// $prov = 'Email';
return User::create([
'name' => $data['name'],
'username' => $data['username'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'provider' => 'Email',
]);
}
}