@@ -115,18 +115,6 @@ public function show(Post $post){
115
115
116
116
## Customisation
117
117
118
- ### Padding
119
-
120
- Change the minimum length of a slug (default: 5)
121
-
122
- ``` php
123
- class Post extends Model {
124
- use HasHashSlug;
125
-
126
- protected static $minSlugLength = 10;
127
- }
128
- ```
129
-
130
118
### Salts
131
119
132
120
The uniqueness of hashslug series per model and app installation depends on having unique salts.
@@ -141,7 +129,7 @@ To change the 'application salt', create file `config/hashslug.php` then add the
141
129
<?php
142
130
143
131
return [
144
- 'appsalt' => 'your-application-salt'
132
+ 'appsalt' => 'your-application-salt'
145
133
];
146
134
```
147
135
@@ -153,29 +141,52 @@ To use a custom model salt instead of the classname:
153
141
154
142
``` php
155
143
class Post extends Model {
156
- use HasHashSlug;
144
+ use HasHashSlug;
157
145
158
- protected static $modelSalt = "posts";
146
+ protected static $modelSalt = "posts";
159
147
}
160
148
```
161
149
162
150
This might be a good idea to do, if you have several extended classes of the same model and you need hashslugs to be consistent.
163
151
152
+ ### Padding
153
+
154
+ Change the minimum length of a slug (default: 5)
155
+
156
+ ``` php
157
+ class Post extends Model {
158
+ use HasHashSlug;
159
+
160
+ protected static $minSlugLength = 10;
161
+ }
162
+ ```
164
163
165
- #### Alphabet
164
+ You can set the minimum length of a slug globally too, by adding the following line to ` config/hashslug.php ` :
165
+
166
+ ``` php
167
+ 'minSlugLength' => 10
168
+ ```
169
+
170
+ ### Alphabet
166
171
167
172
The default alphabet is ` abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 `
168
173
169
174
This can be changed:
170
175
171
176
``` php
172
177
class Post extends Model {
173
- use HasHashSlug;
178
+ use HasHashSlug;
174
179
175
- protected static $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
180
+ protected static $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
176
181
}
177
182
```
178
183
184
+ You can set the alphabet globally too, by adding the following line to ` config/hashslug.php ` :
185
+
186
+ ``` php
187
+ 'alphabet' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
188
+ ```
189
+
179
190
## Similar packages and how is this one different
180
191
181
192
#### [ Laravel Hashids] ( https://github.com/vinkla/laravel-hashids )
0 commit comments