I am running Laravel 5.2, on Windows 8.1 using XAMPP with php 7.2, and I am trying to register a user using laravel auth register form with sqlite database. However when I try insert new record to table users
I got error.
SQLSTATE[HY000]: General error: 1 no such table: user
When I migrate database it creates users table. But when I try to insert new record in users
table with register form it tries to access user
table. So I created user
table in database it works fine but the record is inserted in users
table and not in user
table.
Migration
public function up(){
Schema::create('users', function (Blueprint $table) {
$table->increments('user_id');
$table->string('name');
$table->string('role');
$table->string('username');
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
public function down(){
Schema::drop('users');
}
User model
class User extends Authenticatable{
protected $primaryKey = 'user_id';
protected $fillable = [
'name', 'role', 'username', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
}
AuthController
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
protected $redirectTo = '/';
protected $username = 'username';
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'role' => 'required|max:7',
'username' => 'required|unique:user',
'password' => 'required|min:6|confirmed',
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'role' => $data['role'],
'username' =>$data['username'],
'password' => bcrypt($data['password']),
]);
}
}
thanks for help and sorry for bad english.