Skip to content

Commit 50b48f4

Browse files
Update README.md
1 parent ea13221 commit 50b48f4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,12 @@ php artisan morph-map:clear
142142
You can also determine morph class values programmatically by using a custom resolver. For example, you could use the following to automatically derive the value based on the singular form of the model's table name:
143143

144144
```php
145-
use Illuminate\Support\Str;
146-
use Spatie\LaravelMorphMapGenerator\MorphMapGenerator;
147-
148145
MorphMapGenerator::resolveUsing(fn ($model) => Str::singular($model->getTable()));
149146
```
150147

151-
You may set the resolver in the `boot` method of your `AppServiceProvider` or a separate service provider if needed.
148+
Be warned! When the output of the closure above is not stable then you'll manually need to update all the `morhp_type` columns within your database. Using something like the table name is a good idea since those do not change that often.
149+
150+
You may set the resolver in the `boot` method of one of your service providers.
152151

153152
### Models outside your path
154153

0 commit comments

Comments
 (0)