Laravel Relatable

Installation

composer require foxws/laravel-relatable

The migration for the relatables table runs automatically — no vendor:publish step is required, but it can still be published (and customized). Then set migrations to false in the published config before migrating, or both copies run and the second fails with "table already exists":

php artisan vendor:publish --tag="relatable-migrations"
php artisan vendor:publish --tag="relatable-config"
# set 'migrations' => false in config/relatable.php
php artisan migrate

Publish the config file:

php artisan vendor:publish --tag="relatable-config"

Don't add your own migration for the relatables table — both would run, failing with a "relation already exists" error. Publish and edit the package's migration instead, or disable it (see configuration.md).

Then add the InteractsWithRelated trait to your models (see usage.md).