use IlluminateSupportFacadesDB;
// Test database connection
try {
DB::connection()->getPdo();
} catch (Exception $e) {
die("Could not connect to the database. Please check your configuration. error:" . $e );
}
if(DB::connection()->getDatabaseName())
{
echo "conncted sucessfully to database ".DB::connection()->getDatabaseName();
}
DB::connection();
1) go to http://localhost/phpmyadmin .
2) create a new table called job for example
3) go to .env file in your laravel project then change these lignes:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1.
DB_PORT=3306
DB_DATABASE=name_of_database // => name should be exact as the table name you created .. in our example its job
DB_USERNAME=root
DB_PASSWORD=choose_your_password