Looking to hire Laravel developers? Try LaraJobs
This package is not available.

laravel-link-url maintained by rdx

Description
Mutable Laravel links & urls
Author
Last update
2026/03/26 16:40 (dev-master)
License
Links
Downloads
7 784

Comments
comments powered by Disqus
Mutable Laravel links, urls and redirects ==== What? ---- Normal Laravel links, urls and redirects aren't mutable, because they're ready strings. You make them and that's it. You can't add query params after, and you can't add a `#fragment` at all. This makes for unreadable links/urls: $link = link_to_route('users.show', 'Some label here', ['user' => 321, 'report' => 123], ['title' => 'The title of the link', 'id' => "link-{$user->id}"]); Which part is a URL component, and which part a custom query param, and which part an HTML attribute..? How? ---- Add the service provider (happens automatically): rdx\linkurl\LinkUrlServiceProvider::class Make sure `laravelcollective/html` is installed. It makes links. Links, urls and redirects are mutable objects now: // Link: View users echo linkurl_to_route('users.show', 'View user', [$user])->query('report', 14)->fragment('table-reports'); // Link: x echo linkurl_to_route('reports.delete', 'x', [$report])->add('class', 'delete')->withCsrf(); // Url: https://example.com/users/123/edit?return=https%3A%2F%2Fexample.com%2Fusers $url = routeurl('users.edit', [$user])->query('return', route('users.index')); // Redirect: /users/123#table-reports return redirect()->route('users.show', [$user])->fragment('table-reports'); Links and Urls are built in `__toString()` at the last moment.