Skip to content

Commit 03acad3

Browse files
author
Trick
committed
update readme with helper function reference, examples section
1 parent 2c47194 commit 03acad3

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

README.md

+35-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,48 @@ composer require permafrost-dev/laravel-current-route
1717
```
1818
---
1919

20+
#### Helper Functions
21+
22+
```php
23+
24+
// Return a Laravel Route object for the current route.
25+
function current_route();
26+
27+
// Return a class containing information about the current route.
28+
function current_route_info();
29+
30+
// Return the action for the current route.
31+
function current_route_action();
32+
33+
// Return true if one of the specified wildcard patterns matches the name of the current route.
34+
function current_route_matches($patterns);
35+
36+
// Return the name for the current route.
37+
function current_route_name();
38+
39+
// Returns true if $name matches the name of the current route.
40+
function current_route_named($name);
41+
```
42+
2043
#### Usage
21-
WIP
44+
45+
_WIP_
46+
47+
#### Examples
48+
49+
Use `current_route_named()` to generate conditional css classes in a blade template:
50+
```html
51+
<a class="{{ current_route_named('dashboard') ? 'active' : 'inactive' }}"
52+
href="{{ route('dashboard') }}">Dashboard
53+
</a>
54+
```
2255

2356
---
2457

2558
#### Testing
2659

2760
``` bash
28-
$ vendor/bin/phpunit tests
61+
$ vendor/bin/phpunit
2962
```
3063

3164
---

0 commit comments

Comments
 (0)