数据库种子文件中的Laravel路由功能


Laravel route function in db seeder file

我正在尝试从命名路由获取url。当我在头文件

中调用方法时
<a href="{{route('cmsPage', 'thematic_areas')}}" class="dropdown-toggle" data-hover="dropdown">Thematic Areas<b class="caret"></b></a>

结果是正确的

http://hassaan.discover.local/page/thematic_areas

而当相同的方法在db种子文件

中调用时
AdminNavBar::create(array('name'=>'Thematic Area', 'link'=>route('cmsPage', 'thematic_areas'), 'parent_id'=>'0'));

结果不正确。(从php工匠运行种子后存储在数据库中的URL)

http://localhost/page/thematic_areas

我不明白为什么基础URL在播种时变得不同

看起来像artisan正在选择一个不同的环境配置到您的web服务器。config/app.php中的url设置默认为http://localhost

尝试在调用artisan db:seed

时使用--env=local(或任何正确的环境)标志。