Skip to content

Commit 4f6bfd9

Browse files
authored
Merge pull request #117 from dimitriacosta/fix/en-docs
Fix en doc miles
2 parents 4ffa313 + 6a63822 commit 4f6bfd9

8 files changed

Lines changed: 270 additions & 158 deletions

docs/access-handler.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ Just pass one of the following options as a field attribute or menu item value:
1818

1919
*WARNING*: note this package will only prevents the elements from appearing in the front end, you still need to protect the backend access using middleware, etc.
2020

21-
##Usage
21+
## Usage
2222

2323
#### Form fields
2424

25-
`{!! Field::select('user_id', null, ['role' => 'admin'])`
25+
```blade
26+
{!! Field::select('user_id', null, ['role' => 'admin']);
27+
```
2628

2729
#### Menu items
2830

29-
```
31+
```php
3032
// config/menu.php
3133

3234
return [
@@ -44,7 +46,9 @@ return [
4446
];
4547
```
4648
47-
`{!! Menu::make('menu.items') !}}`
49+
```blade
50+
{!! Menu::make('menu.items') !!}
51+
```
4852

4953
## Gate authorization
5054

@@ -56,14 +60,19 @@ If it is an array, the first position of the array will be the name of the abili
5660

5761
Examples:
5862

59-
`{!! Field::text('change-password', ['allows' => 'change-password']) !!}`
60-
`{!! Field::select('category', $options, ['allows' => ['change-post-category', $category]]) !!}`
63+
```blade
64+
{!! Field::text('change-password', ['allows' => 'change-password']) !!}
65+
```
66+
67+
```blade
68+
{!! Field::select('category', $options, ['allows' => ['change-post-category', $category]]) !!}
69+
```
6170

6271
If you are building menus, you can use dynamic parameters to pass values to the gate.
6372

6473
In the following example we will define a dynamic 'post' parameter, and pass it using setParam when building the menu:
6574

66-
```
75+
```php
6776
// config/menu.php
6877

6978
return [
@@ -76,7 +85,9 @@ return [
7685
];
7786
```
7887
79-
`{!! Menu::make('menu.items')->setParam('post', $post)->render() !}}`
88+
```blade
89+
{!! Menu::make('menu.items')->setParam('post', $post)->render() !!}
90+
```
8091
8192
## Customization
8293

@@ -86,18 +97,18 @@ If you are working on a complex project with lots of different access rules, etc
8697

8798
If you want to use the access handler class as a standalone component, please add this global alias in `config/app.php`
8899

89-
```
90-
'aliases' => [
100+
```php
101+
'aliases' => [
91102
// ...
92103
'Access' => Styde\Html\Facades\Access,
93104
// ...
94-
],
105+
],
95106
```
96107

97108
Then you can use the facade wherever you want:
98109

99-
```
100-
@if (Access:check(['roles' => ['admin, 'editor']]))
110+
```blade
111+
@if (Access:check(['roles' => ['admin', 'editor']]))
101112
<p>
102113
<a href='{{ url('admin/posts', [$post->id]) }}'>
103114
Edit this page
@@ -110,12 +121,14 @@ Then you can use the facade wherever you want:
110121

111122
You can deactivate this component in the configuration:
112123

113-
```
124+
```php
114125
//config/html.php
126+
115127
return [
116128
//..
117129
'control_access' => true,
118130
//..
119131
];
120132
```
133+
121134
By doing this, the callback, logged and roles attributes will simply be ignored and all users will be able to see all items.

docs/alert-messages.md

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,42 @@
22

33
This component will allow you to generate complex alert messages.
44

5-
```
6-
Alert::info('Your account is about to expire')
7-
->details('Renew now to learn about:')
8-
->items([
9-
'Laravel',
10-
'PHP,
11-
'And more',
12-
])
13-
->button('Renew now!', '#', 'primary');
5+
```php
6+
Alert::info('Your account is about to expire')
7+
->details('Renew now to learn about:')
8+
->items([
9+
'Laravel',
10+
'PHP',
11+
'And more',
12+
])
13+
->button('Renew now!', '#', 'primary');
1414
```
1515

1616
The messages will persist in the session until they are presented to the user with:
1717

18-
`{!! Alert::render() !!}`
18+
```blade
19+
{!! Alert::render() !!}
20+
```
1921

2022
## Create new alert messages
2123

2224
You can generate new alert messages with:
2325

24-
`{!! Alert::message('This is a message', 'alert-type') !!}`
26+
```blade
27+
{!! Alert::message('This is a message', 'alert-type') !!}
28+
```
2529

2630
The first argument is the text of the message, and the second one is the type of alert.
2731

2832
For example:
2933

30-
```
34+
```php
3135
Alert::message('The end is near', 'danger');
3236
```
3337

3438
You can also use magic methods, the name of the method then becomes the alert type:
3539

36-
```
40+
```php
3741
Alert::success("It's all good now");
3842
```
3943

@@ -45,39 +49,49 @@ You can specify more options by method chaining:
4549

4650
You can pass a more detailed message chaining the details() method:
4751

48-
`{!! Alert::info('Some info')->details('A more detailed explanation goes here') !!}`
52+
```php
53+
{!! Alert::info('Some info')->details('A more detailed explanation goes here') !!}
54+
```
4955

5056
### call to actions
5157

5258
You can assign buttons to an alert message:
5359

54-
`{!! Alert::info()->button('Call to action', 'some-url', 'primary') !!}`
60+
```blade
61+
{!! Alert::info()->button('Call to action', 'some-url', 'primary') !!}
62+
```
5563

5664
### html
5765

5866
You can directly pass HTML to the alert message
5967

60-
`{!! Alert::info()->html('<strong>HTML goes here</strong>') !!}`
68+
```blade
69+
{!! Alert::info()->html('<strong>HTML goes here</strong>') !!}
70+
```
6171

6272
Be careful since this won't be escaped
6373

6474
### view
6575

6676
You can even render a partial inside an alert message:
6777

68-
`{!! Alert::info()->view('partials/alerts/partial') !!}`
78+
```blade
79+
{!! Alert::info()->view('partials/alerts/partial') !!}
80+
```
6981

7082
### items
7183

7284
You can pass an array of items (maybe an error list):
7385

74-
`{!! Alert::danger('Please fix these errors')->items($errors) !!}`
86+
```blade
87+
{!! Alert::danger('Please fix these errors')->items($errors) !!}
88+
```
7589

7690
## Persist alert messages
7791

7892
Add the following middleware to the `$middleware` array in `app/Http/Kernel.php` **BEFORE** the `\App\Http\Middleware\EncryptCookies`:
7993

80-
```
94+
```php
8195
protected $middleware = [
8296
//...
8397
\Styde\Html\Alert\Middleware::class
@@ -95,8 +109,9 @@ If the `'translate_texts'` options is set to true in the configuration (it's tru
95109

96110
If you don't need to use the translator component, just set translate_texts to false in the configuration:
97111

98-
```
112+
```php
99113
//config/html.php
114+
100115
return [
101116
//...
102117
'translate_texts' => false
@@ -108,8 +123,12 @@ return [
108123

109124
By default, the alert messages will be rendered with the default template, located in themes/[theme]/alert, for example, for the Bootstrap theme that would be:
110125

111-
`vendor/styde/html/themes/bootstrap/alert.blade.php`
126+
```bash
127+
vendor/styde/html/themes/bootstrap/alert.blade.php
128+
```
112129

113130
You can pass a custom template as the first argument of the render() method, i.e.:
114131

115-
`{!! Alert::render('partials/custom-alert-template') !!}`
132+
```blade
133+
{!! Alert::render('partials/custom-alert-template') !!}
134+
```

0 commit comments

Comments
 (0)