php – Clearable error extracting data

Question:

Migrate doesn't give any error and I can also populate the table normally with seed. But when I try to extract data from my database, it doesn't work.

namespace App\Http\Controllers;

use App\Todo;
use Illuminate\Http\Request;

class TodosController extends Controller
{
    public function index(){
        $todos = Todo::all();

        return view('todos')->with('todos', $todos);
    }
}

The error I get:

"SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) (SQL: select * from todos )"

My .env file:

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:jvqNxaeClqTx0iU7pV9/oBo7Ca66CR8hAoga/Y236Qs=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=new-project
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

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}"

I've already tried using:

C:\Users\Antony\Desktop\todos\blog>php artisan config:clear
Configuration cache cleared!

But it continued the same thing. Does anyone know how I can resolve this?

Answer:

I managed to resolve it. In addition to the clear config, it was necessary to use:

php artisan cache:clear
php artisan config:cache
Scroll to Top