所以我有一些問題與生成一個獨特的完全隨機customerid。Laravel 5.1 AuthController用戶註冊唯一隨機ID
我所嘗試的一切都會在我的數據庫中給我一個空白列,誰能告訴我我做錯了什麼!
在此先感謝這裏是我的代碼:
protected function validator(array $data)
{
return Validator::make($data, [
'username' => 'required|max:255|unique:gebruikers',
'email' => 'required|max:255|unique:gebruikers',
'password' => 'required|confirmed|min:6',
'customerid' => 'unique:gebruikers'
]);
}
而且
protected function create(array $data)
{
return User::create([
'username' => $data['username'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'customerid' => str_random(30),
]);
}
和register.blade.php:
<form method="POST" action="/auth/register">
{!! csrf_field() !!}
<div>
<input type="hidden" name="customerid">
Name
<input type="text" name="username" value="{{ old('username') }}">
</div>
<div>
Email
<input type="email" name="email" value="{{ old('email') }}">
</div>
<div>
Password
<input type="password" name="password">
</div>
<div>
Confirm Password
<input type="password" name="password_confirmation">
</div>
<div>
<button type="submit">Register</button>
</div>
</form>
質量分配是不是從用戶收集數據創建一個模型是個好主意! – revo
已經將它改回=>哈哈,不過謝謝..仍然沒有固定它順便說一句。你知道任何解決方案嗎? –
你的'gebruikers'表中有'customerid'字段嗎? – revo