Reputation: 21
It is showing the following error
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test1.users' doesn't exist (SQL: select * from
users
whereuserName
= admin limit 1)
but here is the think that I don't have a table named as users
my table name is login
here is my login controller code
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Input;
use App\Login;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Auth;
class LoginController extends Controller {
public function index(){
return view('login/login');
}
public function show(){
return view('login/login');
}
public function login(){
$uname = Input::get('username');
$pwd = Input::get('password');
// echo "$uname";
// echo "$pwd";
if (Auth::attempt(array('userName' => $uname, 'password' => $pwd))){
return Redirect::to('home');
}
else {
return Redirect::to('login');
}
}
}
my .env
is as follows
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:Zm3uZ82dtjozo68rs2cGAlXXmzj9EuueqCcKsC73VTo=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test1
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Upvotes: 0
Views: 248
Reputation: 133
but here is the think is i don't have a table named as users my table name is login
If your users table name is login, please update your User.php under /app/ and update the user model to use 'login' table
protected $table = 'login';
Upvotes: 2
Reputation: 2775
The error means: connection to the DB is ok, but we not have table users
inside test1
database. So please check users
table inside test1
database...
p.s. Laravel ships with several pre-built authentication controllers, you can use it just with php artisan make:auth
, read more.
Upvotes: 0