Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以只获取上一页的路径?像 URL::previous() 但没有整个域像/something?
/something
为此编写了我自己的函数:
在 vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php 我添加
public function previousPath() { $parsed = parse_url($this->previous()); return $parsed['path']; }
在函数下方previous(),现在您可以执行URL::previousPath()仅返回不带域的路径。
previous()
URL::previousPath()