常规错误:1364字段"remember_token"没有默认值 [英] General error: 1364 Field 'remember_token' doesn't have a default value
问题描述
我是laravel的新手.我想将管理员凭据插入数据库.
I m new to laravel. I wanted to insert the admin credentials into database.
public function verify() {
$username = Input::get('username');
$password = Input::get('password');
if (!Admin::count()) {
$user = new Admin;
$user->username = Input::get('username');
$user->password = $user->password = Hash::make(Input::get('password'));
$user->save();
return Redirect::to('/admin/login');
} else {
if (Auth::attempt(array('username' => $username, 'password' => $password))) {
echo("i m in if");
if (Session::has('pre_admin_login_url')) {
$url = Session::get('pre_admin_login_url');
Session::forget('pre_admin_login_url');
return Redirect::to($url);
} else {
$admin = Admin::where('username', 'like', '%' . $username . '%')->first();
Session::put('admin_id', $admin->id);
return Redirect::to('/admin/report')->with('notify', 'installation Notification');
}
} else {
return Redirect::to('/admin/login?error=1');
}
}
管理员模型:
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
class Admin extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'admin';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
我已将数据库的默认值更改为'null',但仍然出现相同的错误.这是由code-canyon构建的应用程序,我不知道文件所在的查询参数.>
I have changed the database to default value to 'null' but still it gives the same error.This was the application built by code-canyon i haven't know about the querying parameter in which files are they exists.
结果:SQLSTATE [HY000]:常规错误:1364字段"remember_token" 没有默认值(SQL:插入
admin
(username
,password
,updated_at
,created_at
)值(admin @ taxinow.com,y $ csyEcrhERoQEszmxNmiOG.bcAZtwC8xeGiF2xyKTd2YLhEbjixm.m,2017-09-21 08:34:24,2017-09-21 08:34:24))
Result:SQLSTATE[HY000]: General error: 1364 Field 'remember_token' doesn't have a default value (SQL: insert into
admin
(username
,password
,updated_at
,created_at
)values(admin@taxinow.com,y$csyEcrhERoQEszmxNmiOG.bcAZtwC8xeGiF2xyKTd2YLhEbjixm.m,2017-09-21 08:34:24, 2017-09-21 08:34:24))
任何帮助将不胜感激.谢谢.
Any help would be appreciated. Thanks.
推荐答案
我在我的应用程序中解决了此问题,我希望您尝试同样的方法. 转到用户表并编辑Remember_token字段,将默认列更新为NULL.
i solved this issue on my application, and i want you to try the same.. go to your users table and edit the remember_token field, update the default column to NULL.
完成此操作后,请尝试再次运行该应用程序,这一次应该可以运行.但是,如果您使用迁移来更新数据库架构(字段/属性),则可以回滚并将此nullable()添加到Remember_token字符串中,从而对该列进行此调整...
once this is done, try running the application again, it should work this time. But if you were using migrations to update your database schema(fields/properties), you could rollback and make this adjustment to that column by adding this nullable() to the remember_token string...
$table->string('remember_token')->nullable();
我希望这会有所帮助.
i hope this helps.
关于.
这篇关于常规错误:1364字段"remember_token"没有默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!