I am creating a Laravel eCommerce application. I am following this tutorial on youtube: https://www.youtube.com/watch?v=L3EbWJmmyjo&list=PLEhEHUEU3x5oPTli631ZX9cxl6cU_sDaR&index=18
For the Admin section of the website, I am using Voyager. On my localhost, everything seems to be working perfectly:
The landing page (http://localhost:8000):
When I then enter the link: http://localhost:8000/admin it takes me to the http://localhost:8000/admin/login:
I then enter these credentials (images show database as well). As you can see the credentials match and when I press login I'm taken to the dashboard:
All the screenshots so far are on my localhost. When I am trying to install Voyager on my live website it stops working! This is my live web address: https://janinevalerieaesthetics.com
I am hosting using Forge and Envoyer. And they are linking using my GitLab account: https://gitlab.com/rossi99/salonwebsite
I connect to my Forge server using ssh through my terminal using this link: ssh forge@janinevalerieaesthetics.com
And then I cd all the way into the current directory (the one that hold all my folders including the 'vendor' file and 'artisan') and then I use the php artisan commands to install the voyager package (https://voyager-docs.devdojo.com/getting-started/installation) :
Installation Steps:
APP_URL=http://localhost
My .env:
APP_URL=https://janinevalerieaesthetics.com
Installation Steps:
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
My .env:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD="**************"
I thne run this command from my terminal forge@salonWebsite:~/janinevalerieaesthetics.com/current$ :
php artisan voyager:install
I then make a user from the same terminal using this command :
php artisan voyager:admin your@email.com --create
Here is my live database tables:
And here is the roles table ( you can see that user with ID 1 is the admin):
But when I navigate to https://janinevalerieaesthetics.com/admin/login it shows the login screen:
But when I log in with the correct credentials, instead of login me in and showing the admin dashboard, it logs me in and takes me to the landing page and when I try to manually get to the log in it just redirects me to the landing page:
I found the answer for anyone else having this issue. When I inspected my 'seeds' directory, I did not have a 'DatabaseSeeder.php' file. I then created this by simply right-clicking and then creating DatabaseSeeder.php in mt seeds directory, I then added this code into it:
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->call(VoyagerDatabaseSeeder::class);
}
}
I then had to back into my terminal and run the following commands:
ssh forge@janinevalerieaesthetics.com
cd janinevalerieaesthetics.com
(this will be your web address, to find this run command "ll -la" after ssh command)
cd current
cd database
cd seeds
vim DatabaseSeeder.php
(this will allow you to see that the most up to date seed it being used, ':q' to exit)
cd ../
(to go back to 'database' directory)
cd ../
(to go back to 'current' directory)
php artisan db:seed
(this will popuate all the roles and tables that voyager needs)
(you might see a message like this, type yes)
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command? (yes/no) [no]:
> yes
This will then populate the database of your live site. I then tried to log in with an existing user and it didn't work. I had to create a new admin user using this command in the '/current$' directory:
php artisan voyager:admin admin@admin.com --create
<replace admin@admin.com with your own user email>
You will then be prompted for a username and password for your admin and once these are entered you can then navigate to: https://yourURL.com/admin/login and enter the details of your user and you will be navigated to you the dashboard!