I am new to laravel and I am currently having issues when I try to view my database through a controller. When I try to use a controller to view my data I get the following error.
"SQLSTATE[HY000] [1049] Unknown database 'laravel'".
If I use artisan tinker I can do an ::all() and view my data, I have also successfully migrated my data over as well. It just for some reason does not seem to like my views.
I have viewed other similar answers which suggested to run
php artisan cache:clear.
This however did not do anything for me.
controller:
class authorsController extends Controller
{
public function index(){
$authorList = \App\Author::all();
//return $authors;
return view('library.authors');
}
}
Inside .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=library
DB_USERNAME=root
DB_PASSWORD=