File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,32 @@ The `url` helper may be used to generate arbitrary URLs for your application. Th
28
28
29
29
// http://example.com/posts/1
30
30
31
+ To generate a URL with query string parameters, you may use the ` query ` method:
32
+
33
+ echo url()->query('/posts', ['search' => 'Laravel']);
34
+
35
+ // https://example.com/posts?search=Laravel
36
+
37
+ echo url()->query('/posts?sort=latest', ['search' => 'Laravel']);
38
+
39
+ // http://example.com/posts?sort=latest&search=Laravel
40
+
41
+ Providing query string parameters that already exist in the path will overwrite their existing value:
42
+
43
+ echo url()->query('/posts?sort=latest', ['sort' => 'oldest']);
44
+
45
+ // http://example.com/posts?sort=oldest
46
+
47
+ Arrays of values may also be passed as query parameters. These values will be properly keyed and encoded in the generated URL:
48
+
49
+ echo $url = url()->query('/posts', ['columns' => ['title', 'body']]);
50
+
51
+ // http://example.com/posts?columns%5B0%5D=title&columns%5B1%5D=body
52
+
53
+ echo urldecode($url);
54
+
55
+ // http://example.com/posts?columns[0]=title&columns[1]=body
56
+
31
57
<a name =" accessing-the-current-url " ></a >
32
58
### Accessing the Current URL
33
59
You can’t perform that action at this time.
0 commit comments