Skip to content

Commit 736a562

Browse files
committed
add readme
1 parent 9c2a8c1 commit 736a562

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/vendor/
2+
.idea

readme.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Laravel Routes to Body Class
2+
3+
Quickly add a unique body class to your view based on your Laravel routes.
4+
5+
## Example
6+
7+
You have a route defined for editing your products:
8+
9+
```php
10+
Route::get(
11+
'/admin/products/{product_id}/edit',
12+
'ProductAdminController@getEdit'
13+
)
14+
```
15+
16+
This library will add the class `admin-products-edit` as a shared view variable automatically.
17+
18+
## Install
19+
20+
### 1 - Require Package
21+
22+
```
23+
composer require zschuessler/laravel-route-to-class
24+
```
25+
26+
### 2 - Add Service Provider to Your App
27+
28+
Add the following line under the `providers` array key in *app/config.php*:
29+
30+
```php
31+
/**
32+
* Custom Service Providers
33+
*/
34+
Zschuessler\RouteToClass\ServiceProvider::class,
35+
```
36+
37+
### 3 - Use It
38+
39+
You now have access to a shared view variable `$route_body_class`. Use it in any of your views like so:
40+
41+
```php
42+
<body class="{{ $route_body_classes ))">
43+
```
44+
45+
## License
46+
47+
This is public domain. Do what you want.

0 commit comments

Comments
 (0)