Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cviebrock committed Nov 29, 2024
1 parent 09fe3c5 commit a4281cf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 11.0.1 - 28-Nov-2024

- Support PHP 8.4 (#616, thanks @SupianIDz)
- Notice that Lumen will be deprecated in the next major release


## 11.0.0 - 12-Mar-2024
Expand Down
55 changes: 33 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

Easy creation of slugs for your Eloquent models in Laravel.

> **NOTE:** These instructions are for the latest version of Laravel.
> [!NOTE]
> These instructions are for the latest version of Laravel.
> If you are using an older version, please install a version of the package
> that [correlates to your Laravel version](#installation).
Expand Down Expand Up @@ -95,12 +96,13 @@ automatically, with minimal configuration.
Depending on your version of Laravel, you should install a different
version of the package.

> **NOTE:** As of version 6.0, the package's version should match the Laravel version.
> [!NOTE]
> As of version 6.0, the package's version should match the Laravel version.
| Laravel Version | Package Version |
|:---------------:|:---------------:|
| 11.0 | ^11.0 |
| 10.0 | ^10.0 |
| 11.0 | ^11.0 |
| 10.0 | ^10.0 |
| 9.0 | ^9.0 |
| 8.0 | ^8.0 |
| 7.0 | ^7.0 |
Expand All @@ -117,6 +119,10 @@ are no longer supported or maintained. See [CHANGELOG.md](CHANGELOG.md) and
the correct README.md for your version (GitHub displays the version in
the _master_ branch by default, which might not be what you want).

> [!WARNING]
> Support for Laravel [Lumen](https://lumen.laravel.com/) will be dropped
> in the 12.0 version of this package.

1. Install the package via Composer:

Expand Down Expand Up @@ -187,7 +193,8 @@ So is retrieving the slug:
echo $post->slug;
```
> **NOTE:** that if you are replicating your models using Eloquent's `replicate()` method,
> [!NOTE]
> If you are replicating your models using Eloquent's `replicate()` method,
> the package will automatically re-slug the model afterwards to ensure uniqueness.
```php
Expand All @@ -200,19 +207,20 @@ $newPost = $post->replicate();
// $newPost->slug is "my-awesome-blog-post-1"
```
> **NOTE:** empty strings, non-strings or other "odd" source values will result in different slugs:
| Source Value | Resulting Slug |
|--------------|-----------------------|
| string | string |
| empty string | _no slug will be set_ |
| `null` | _no slug will be set_ |
| `0` | `"0"` |
| `1` | `"1"` |
| `false` | `"0"` |
| `true` | `"1"` |
(The above values would be subject to any unique or other checks as well.)
> [!NOTE]
> Empty strings, non-strings or other "odd" source values will result in different slugs:
>
> | Source Value | Resulting Slug |
> |--------------|-----------------------|
> | string | string |
> | empty string | _no slug will be set_ |
> | `null` | _no slug will be set_ |
> | `0` | `"0"` |
> | `1` | `"1"` |
> | `false` | `"0"` |
> | `true` | `"1"` |
>
> The above values would be subject to any unique or other checks as well.
## The SlugService Class
Expand Down Expand Up @@ -544,8 +552,9 @@ generated slugs would look something like:
If you want to start counting at a different number (or pass a different value
into your custom `uniqueSuffix` function above), then you can define it here.
> **NOTE:** Prior versions of the package started with a unique
> suffix of `1`. This was switched to `2` in version 8.0.5, as it's a more
> [!NOTE]
> Prior versions of the package started with a unique suffix of `1`.
> This was switched to `2` in version 8.0.5, as it's a more
> "intuitive" suffix value to attach to the second slug.
### includeTrashed
Expand All @@ -567,7 +576,8 @@ Setting this to a positive integer will ensure that your generated slugs are res
to a maximum length (e.g. to ensure that they fit within your database fields). By default,
this value is null and no limit is enforced.
> **NOTE:** If `unique` is enabled (which it is by default), and you anticipate having
> [!NOTE]
> If `unique` is enabled (which it is by default), and you anticipate having
> several models with the same slug, then you should set this value to a few characters
> less than the length of your database field. The reason why is that the class will
> append "-2", "-3", "-4", etc., to subsequent models in order to maintain uniqueness.
Expand Down Expand Up @@ -652,7 +662,8 @@ In instances like these, the package offers hooks into the slugging workflow whe
can use your own functions, either on a per-model basis, or in your own trait that extends
the package's trait.
> **NOTE:** If you are putting these methods into your own trait, you will
> [!NOTE]
> If you are putting these methods into your own trait, you will
> need to indicate in your models that PHP should use _your_ trait methods
> instead of the packages (since a class can't use two traits with the
> same methods), e.g.
Expand Down

0 comments on commit a4281cf

Please sign in to comment.