0

我正在创建一个 Laravel 电子商务应用程序。我在 youtube 上关注本教程:https ://www.youtube.com/watch?v=L3EbWJmmyjo&list=PLEhEHUEU3x5oPTli631ZX9cxl6cU_sDaR&index=18

对于网站的管理部分,我使用的是 Voyager。在我的本地主机上,一切似乎都运行良好:

登陆页面(http://localhost:8000):

在此处输入图像描述

然后当我输入链接:http://localhost:8000/admin 时,它会将我带到 http://localhost:8000/admin/login:

在此处输入图像描述

然后我输入这些凭据(图像也显示数据库)。如您所见,凭据匹配,当我按下登录时,我被带到仪表板:

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

到目前为止所有的屏幕截图都在我的本地主机上。当我尝试在我的实时网站上安装 Voyager 时,它停止工作!这是我的实时网址:https ://janinevalerieaesthetics.com

我正在使用 Forge 和 Envoyer 进行托管。他们正在使用我的 GitLab 帐户进行链接:https ://gitlab.com/rossi99/salonwebsite

我使用 ssh 通过我的终端使用以下链接连接到我的 Forge 服务器:ssh forge@janinevalerieaesthetics.com

然后我一直 cd 进入当前目录(包含我所有文件夹的目录,包括“供应商”文件和“工匠”),然后我使用 php artisan 命令安装 voyager 包(https://voyager- docs.devdojo.com/getting-started/installation):

  1. 更改 .env 文件:

安装步骤:

APP_URL=http://localhost

我的.env:

APP_URL=https://janinevalerieaesthetics.com

安装步骤:

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

我的.env:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD="**************"

我从我的终端 forge@salonWebsite:~/janinevalerieaesthetics.com/current$ 运行这个命令:

php artisan voyager:install

然后我使用这个命令从同一个终端创建一个用户:

php artisan voyager:admin your@email.com --create

这是我的实时数据库表:

在此处输入图像描述

这是角色表(您可以看到 ID 为 1 的用户是管理员):

在此处输入图像描述

但是当我导航到https://janinevalerieaesthetics.com/admin/login时,它会显示登录屏幕:

在此处输入图像描述

但是,当我使用正确的凭据登录时,它不是让我登录并显示管理仪表板,而是让我登录并带我进入登录页面,当我尝试手动登录时,它只会将我重定向到登录页面页:

在此处输入图像描述

4

1 回答 1

0

我为其他遇到此问题的人找到了答案。当我检查我的“种子”目录时,我没有“DatabaseSeeder.php”文件。然后我通过简单地右键单击然后在 mt 种子目录中创建 DatabaseSeeder.php 来创建它,然后我将这段代码添加到其中:

<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $this->call(VoyagerDatabaseSeeder::class);
    }
}

然后我不得不回到我的终端并运行以下命令:

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

然后,这将填充您的实时站点的数据库。然后我尝试使用现有用户登录,但没有成功。我必须在“/current$”目录中使用这个命令创建一个新的管理员用户:

php artisan voyager:admin admin@admin.com --create

<replace admin@admin.com with your own user email>

然后将提示您输入管理员的用户名和密码,输入后您可以导航到:https ://yourURL.com/admin/login并输入您的用户的详细信息,您将被导航到您的仪表板!

于 2020-07-10T11:39:22.043 回答