I got many solution for this problem but none are working.
This is my controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Doctor;
class DoctorController extends Controller
{
public function index(){
$doctors = Doctor::all();
return $doctors;
return "this is a doctorController";
}
}
and This is my model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Doctor extends Model
{
//
}
and this is my Route.php
Route::resource("doctor","DoctorController");
This is my .env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=medical
DB_USERNAME=root
DB_PASSWORD=
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
I followed the solution of this http://tutsnare.com/access-denied-for-user-homesteadlocalhost-laravel-5/ and Laravel 5.2: PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)
but none of them working .what should i do?
Its database connection error which says its password protected. you can't leave it blank then (DB_PASSWORD=?) try using 'root' as password if you never assigned anthing different before.
If possible provide your config/database.php file. or go to config/database.php file and make changes as :
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'YOUR_DB_HOST'),
'database' => env('DB_DATABASE', 'YOUR_DB_DATABASE'),
'username' => env('DB_USERNAME', 'YOUR_DB_USERNAME'),
'password' => env('DB_PASSWORD', 'YOUR_DB_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
If there is no password for the database, remove DB_PASSWORD=
from the .env
file. See if that solves your issue.
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.