@@ -18,11 +18,12 @@ Save a model "quietly" without broadcasting any events or firing off any observe
1818``` php
1919use Yab\Mint\Traits\SavesQuietly;
2020
21- class Example extends Model
21+ class Example extends Model
2222{
2323 use SavesQuietly;
2424}
2525```
26+
2627``` php
2728$example->saveQuietly();
2829```
@@ -34,11 +35,12 @@ Allow for models to be archived or unarchived based on an "archived_at" field on
3435``` php
3536use Yab\Mint\Traits\Archivable;
3637
37- class Example extends Model
38+ class Example extends Model
3839{
3940 use Archivable;
4041}
4142```
43+
4244``` php
4345$example->archive();
4446$example->unarchive();
@@ -54,11 +56,12 @@ Models which are marked as "immutable" will throw an ImmutableDataException if u
5456``` php
5557use Yab\Mint\Traits\Immutable;
5658
57- class Example extends Model
59+ class Example extends Model
5860{
5961 use Immutable;
6062}
6163```
64+
6265``` php
6366// No problem
6467$example = Example::create([
@@ -101,10 +104,40 @@ A custom cast for storing monetary values as cents in the database while fetchin
101104``` php
102105use Yab\Mint\Casts\Money;
103106
104- class Example extends Model
107+ class Example extends Model
105108{
106109 protected $casts = [
107110 'price' => Money::class,
108111 ];
109112}
110113```
114+
115+ ### Slugify
116+
117+ Create slugs that are unique and never collide with each other
118+
119+ ``` php
120+ use Yab\Mint\Trails\Slugify;
121+
122+ class Example extends Model
123+ {
124+ use Slugify
125+ }
126+ ```
127+
128+ By default the Slugify trait uses the ` name ` property on your model. You can change this
129+ by overriding the ` getSlugKeyName ` method.
130+
131+ ``` php
132+ use Yab\Mint\Trails\Slugify;
133+
134+ class Example extends Model
135+ {
136+ use Slugify;
137+
138+ public static function getSlugKeyName(): string
139+ {
140+ return 'title';
141+ }
142+ }
143+ ```
0 commit comments