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');
}
}
Admin Model:
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');
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.
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.
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.
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.
Regards.
Go to Admin model and add it to the $protected
fillable as an array
protected $fillable = [
'user_name','remember_token',
];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.