Laravel: URL::to('/') port number for localhost not included in db seed files

☆樱花仙子☆ 提交于 2020-04-10 15:09:10

问题


I am running a local server on port 4567. I am trying to make it so that when my database seeds I save a reference to the home page on my site in my db. However I noticed when I run URL::to('/') in my seeds it only includes "localhost" without the port, but if I include it in my view code it comes out as "localhost:4567". Why is this? How can I fix it, if possibly, without writing if statement conditionals about what production environment I am in? Thank you.

Seed File result of URL::to('/')

http://localhost

View File result of URL::to('/')

http://localhost:4567

回答1:


Either set APP_URL in env file

APP_URL=http://localhost:4567

Or set url in config/app.php

'url' => env('APP_URL', 'http://localhost:4567'),


来源:https://stackoverflow.com/questions/28105113/laravel-urlto-port-number-for-localhost-not-included-in-db-seed-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!