Refactor tag system
This pull request introduces significant changes to the handling of tags in the application. It replaces the previous string-based tag system with a relational model using a new Tag entity. This change affects multiple parts of the codebase, including models, controllers, resources, and database interactions. The key improvements include better tag management, relational mapping between photos and tags, and enhanced query capabilities.
Tag System Overhaul:
-
Introduction of the
TagModel:- A new
Tagmodel (app/Models/Tag.php) has been added to represent tags as entities in the database. It includes methods for relational mapping with photos and a utility methodTag::from()to fetch or create tags dynamically.
- A new
-
Relational Mapping Between Photos and Tags:
- The
Photomodel now includes atags()method to define aBelongsToManyrelationship with theTagmodel, replacing the previous array-based tag handling.
- The
-
Refactoring of Tag Album:
- The
TagAlbummodel now uses theTagArrayCastclass to handle tags asTagobjects instead of strings.
- The
Controller and Resource Updates:
-
Tag Management in Controllers:
- Controllers such as
PhotoControllerandAlbumControllernow handle tags using theTagmodel, including syncing tags with photos and dynamically creating tags if they don't exist. [1] [2]
- Controllers such as
-
Resource Representation:
- Tags are now represented as their
namein API resources likePhotoResourceandTagAlbumResource. This ensures API responses are more user-friendly and consistent. [1] [2]
- Tags are now represented as their
Query and Search Enhancements:
-
Improved Query Handling:
- Queries now include tags as a relation, allowing for more efficient data retrieval and filtering. This applies to various parts of the application, such as
PhotoSearchandFrameController. [1] [2]
- Queries now include tags as a relation, allowing for more efficient data retrieval and filtering. This applies to various parts of the application, such as
-
Custom Query Builder for Tags:
- A specialized
TagBuilderclass has been introduced to extend query capabilities for theTagmodel.
- A specialized
These changes collectively enhance the application's ability to manage and query tags, improving both backend efficiency and frontend usability.
Codecov Report
:x: Patch coverage is 96.51163% with 3 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 90.82%. Comparing base (8dd4b28) to head (de216e2).
:warning: Report is 4 commits behind head on master.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
See #3616