refactor: Remove TagItem model and replace with standard Laravel pivot table (#198)
Commit: 4d4a50814dfd34923d4b514461383a8c38b4c668
Date: 2025-07-07 15:48:56 +0200
Author: PascalHavelange
Commit Message
refactor: Remove TagItem model and replace with standard Laravel pivot table (#198)
refactor: replace TagItem model with standard Laravel pivot table
- Drop tag_items table and create item_tag pivot table with composite primary key
- Remove TagItem model, factory, seeder, controller, resource, and all related tests
- Update Item and Tag models to use standard belongsToMany relationships with withTimestamps()
- Replace TagItemSeeder with ItemTagSeeder using Eloquent attach() methods
- Update all unit and feature tests to use attach() instead of TagItem::factory()
- Remove TagItem API routes and controller
- Update CHANGELOG.md to document the refactoring
This simplifies the tagging system by using Laravel's standard many-to-many
relationship pattern instead of an over-engineered pivot model approach.
Co-authored-by: Pascal HAVELANGE <havelangep@hotmail.com>
Files Changed
- 📝 Modified:
CHANGELOG.md
- 📝 Modified:
README.md
- ❌ Deleted:
app/Http/Controllers/TagItemController.php
- ❌ Deleted:
app/Http/Resources/TagItemResource.php
- 📝 Modified:
app/Models/Item.php
- 📝 Modified:
app/Models/Tag.php
- ❌ Deleted:
app/Models/TagItem.php
- ❌ Deleted:
database/factories/TagItemFactory.php
- ✅ Added:
database/migrations/2025_07_07_132733_drop_tag_items_and_create_item_tag_pivot_table.php
- 📝 Modified:
database/seeders/DatabaseSeeder.php
- ✅ Added:
database/seeders/ItemTagSeeder.php
- ❌ Deleted:
database/seeders/TagItemSeeder.php
- 📝 Modified:
docs/_openapi/api.json
- 📝 Modified:
docs/guidelines/coding-guidelines.md
- 📝 Modified:
routes/api.php
- 📝 Modified:
tests/Feature/Api/Item/ScopeTest.php
- 📝 Modified:
tests/Feature/Api/Tag/ScopeTest.php
- ❌ Deleted:
tests/Feature/Api/TagItem/AnonymousTest.php
- ❌ Deleted:
tests/Feature/Api/TagItem/DestroyTest.php
- ❌ Deleted:
tests/Feature/Api/TagItem/IndexTest.php
- ❌ Deleted:
tests/Feature/Api/TagItem/ShowTest.php
- ❌ Deleted:
tests/Feature/Api/TagItem/StoreTest.php
- ❌ Deleted:
tests/Feature/Api/TagItem/UpdateTest.php
- 📝 Modified:
tests/Unit/Item/FactoryTest.php
- 📝 Modified:
tests/Unit/Tag/FactoryTest.php
- ❌ Deleted:
tests/Unit/TagItem/FactoryTest.php
Links
This documentation was automatically generated from Git commit data.