Full error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'quotesapp.admin' doesn't exist (SQL: select count(*) as aggregate from `admin` where `username` = Admin)
I know that an error is a mismatch between the name that appears in the error log and how it is defined everywhere (in the database folder, but I can’t solve the problem. I searched and found this one , but even after I implemented solution (shown below), I still get the same error.
I am using Laravel 5.2. I have a table adminsin my database directory that looks like this:
class CreateAdminsTable extends Migration
{
public function up()
{
Schema::create('admins', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('username')->unique();
$table->string('password');
$table->rememberToken();
});
}
public function down()
{
Schema::drop('admins');
}
}
The administrator model looks like this:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Authenticatable;
class Admin extends Model implements \Illuminate\Contracts\Auth\Authenticatable
{
protected $table = 'admins';
use Authenticatable;
}
?>
Here is the corresponding route causing the error:
Route::post('/admin/register', [
'uses' => 'AdminController@postRegister',
'as' => 'register'
]);
And here is the method postRegister
public function postRegister(Request $request) {
$this->validate($request, [
'username' => 'required|unique:admin|max:30|min:3',
'password' => 'required|min:5',
'password_confirm' => 'required'
]);
$password = $request['password'];
$passwordConfirm = $request['password_confirm'];
if ($password !== $passwordConfirm) {
return redirect()->back()->with(['fail' => 'password fields do not match!']);
}
$admin = new Admin();
$admin->username = $request['username'];
$admin->password = $request['password'];
$admin->save();
return redirect()->route('index');
}
php artisan migrate , " ". , . "" phpmyadmin.
1: