阅读(242) (4)

Laravel 8 生成基础 URL

2021-06-25 09:31:59 更新

辅助函数 url 可以用于应用的任何一个 URL。生成的 URL 将自动使用当前请求中的方案 (HTTP or HTTPS) 和主机:

$post = AppModelsPost::find(1);

echo url("/posts/{$post->id}");

// http://example.com/posts/1