我有問題在laravel 5.2當我註冊一個新的用戶與一個表所有記錄插入數據庫中的表用戶但我的remember_token字段始終爲空 如果我單擊註銷將插入remember_token。但我想獨自從這種形式 創建多個用戶,因爲我希望管理員必須創建用戶帳戶的權利 我想,當我沒有註銷創建用戶帳戶每次laravel 5.2創建多用戶
控制器
class AuthController extends Controller
{
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
protected function create(array $data)
{
$user =User::create([
'username' => $data['username'],
'droit'=> $data['droit'],
'idUtilisateur'=> $data['idUtilisateur'],
'password' => bcrypt($data['password']),
]);
return $user;
}
}
爲
查看
<form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
<label for="username" class="col-md-4 control-label">Nom d'utilisateur</label>
<div class="col-md-6">
<input id="username" type="text" class="form-control" name="username" value="{{ old('username') }}">
@if ($errors->has('username'))
<span class="help-block">
<strong>{{ $errors->first('username') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Mot de Passe </label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password">
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
...
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
<i class="fa fa-btn fa-user"></i> Ajouter
</button>
</div>
</div>
</form>
型號
class CreateUsersTable extends Migration
{
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('username')->unique();
$table->string('password');
$table->integer('droit');
$table->integer('idUtilisateur');
$table->integer('EtatCompte');
$table->rememberToken();
$table->timestamps();
});
}
謝謝
爲什麼你需要rememberToken? – madalinivascu