Skip to content

Add LogsActivity trait to models missing it#2248

Merged
glennjacobs merged 2 commits intolunarphp:1.xfrom
ryanmitchell:fix/missing-activity-logs
Aug 14, 2025
Merged

Add LogsActivity trait to models missing it#2248
glennjacobs merged 2 commits intolunarphp:1.xfrom
ryanmitchell:fix/missing-activity-logs

Conversation

@ryanmitchell
Copy link
Contributor

@ryanmitchell ryanmitchell commented Jul 18, 2025

Some of the core models are missing activity logging which we're trying to use across the system to give our clients visibility on all changes.

This PR adds them.

Summary by CodeRabbit

  • New Features
    • Added activity logging capabilities to various models across the platform, enabling automatic tracking of changes and actions for staff, customers, products, discounts, tax settings, shipping, and more. This enhancement improves visibility and traceability of important events throughout the system.

@vercel
Copy link

vercel bot commented Jul 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 1:44pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 18, 2025

Walkthrough

The changes update multiple model classes across the codebase to include the LogsActivity trait from Lunar\Base\Traits. This trait is added to enable activity logging capabilities in each model. No other modifications to methods, properties, or logic are present in these updates.

Changes

Files (Grouped) Change Summary
packages/admin/src/Models/Staff.php Added LogsActivity trait to Staff model.
packages/core/src/Models/AttributeGroup.php
.../CollectionGroup.php
.../Customer.php
.../CustomerGroup.php
.../Discount.php
.../ProductOption.php
.../ProductType.php
.../Tag.php
.../TaxClass.php
.../TaxRate.php
.../TaxZone.php
Added LogsActivity trait to various core models.
packages/table-rate-shipping/src/Models/ShippingExclusionList.php
.../ShippingMethod.php
.../ShippingRate.php
.../ShippingZone.php
Added LogsActivity trait to table-rate shipping models.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cec97ad and 5433bc2.

📒 Files selected for processing (16)
  • packages/admin/src/Models/Staff.php (2 hunks)
  • packages/core/src/Models/AttributeGroup.php (2 hunks)
  • packages/core/src/Models/CollectionGroup.php (2 hunks)
  • packages/core/src/Models/Customer.php (2 hunks)
  • packages/core/src/Models/CustomerGroup.php (2 hunks)
  • packages/core/src/Models/Discount.php (2 hunks)
  • packages/core/src/Models/ProductOption.php (2 hunks)
  • packages/core/src/Models/ProductType.php (2 hunks)
  • packages/core/src/Models/Tag.php (2 hunks)
  • packages/core/src/Models/TaxClass.php (2 hunks)
  • packages/core/src/Models/TaxRate.php (2 hunks)
  • packages/core/src/Models/TaxZone.php (2 hunks)
  • packages/table-rate-shipping/src/Models/ShippingExclusionList.php (1 hunks)
  • packages/table-rate-shipping/src/Models/ShippingMethod.php (2 hunks)
  • packages/table-rate-shipping/src/Models/ShippingRate.php (2 hunks)
  • packages/table-rate-shipping/src/Models/ShippingZone.php (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
packages/table-rate-shipping/src/Models/ShippingRate.php (1)
Learnt from: ryanmitchell
PR: lunarphp/lunar#2244
File: packages/core/src/DiscountTypes/BuyXGetY.php:126-126
Timestamp: 2025-07-18T06:55:56.424Z
Learning: In the Lunar e-commerce system, CartLine objects will not have zero quantity values by the time they reach the BuyXGetY discount sorting logic, as this is handled by code elsewhere in the system.
🧬 Code Graph Analysis (1)
packages/table-rate-shipping/src/Models/ShippingExclusionList.php (2)
packages/table-rate-shipping/database/factories/ShippingExclusionListFactory.php (1)
  • ShippingExclusionListFactory (8-18)
packages/core/src/Base/BaseModel.php (1)
  • BaseModel (8-25)
🔇 Additional comments (22)
packages/core/src/Models/Tag.php (1)

9-9: LGTM: LogsActivity trait properly integrated.

The trait import and usage are correctly implemented, enabling activity logging for the Tag model.

Also applies to: 23-23

packages/core/src/Models/TaxZone.php (1)

12-12: LGTM: LogsActivity trait properly integrated.

The trait import and usage are correctly implemented, enabling activity logging for the TaxZone model.

Also applies to: 30-30

packages/table-rate-shipping/src/Models/ShippingZone.php (1)

10-10: LGTM: LogsActivity trait properly integrated.

The trait import and usage are correctly implemented, enabling activity logging for the ShippingZone model.

Also applies to: 19-19

packages/core/src/Models/Customer.php (1)

16-16: LGTM: LogsActivity trait properly integrated.

The trait import and usage are correctly implemented, enabling activity logging for the Customer model. The trait integrates well with the existing multiple traits.

Also applies to: 40-40

packages/core/src/Models/TaxClass.php (1)

10-10: LGTM: LogsActivity trait properly integrated.

The trait import and usage are correctly implemented, enabling activity logging for the TaxClass model.

Also applies to: 25-25

packages/table-rate-shipping/src/Models/ShippingExclusionList.php (2)

9-9: LGTM! Import statement properly added.

The LogsActivity trait import is correctly placed and follows PSR-12 conventions.


15-15: LGTM! Trait usage correctly implemented.

The LogsActivity trait is properly used within the class and will enable activity logging for the ShippingExclusionList model.

packages/core/src/Models/ProductType.php (2)

11-11: LGTM! Import statement properly added.

The LogsActivity trait import is correctly placed and follows PSR-12 conventions.


25-25: LGTM! Trait usage correctly implemented.

The LogsActivity trait is properly used within the class and will enable activity logging for the ProductType model.

packages/core/src/Models/TaxRate.php (2)

10-10: LGTM! Import statement properly added.

The LogsActivity trait import is correctly placed and follows PSR-12 conventions.


26-26: LGTM! Trait usage correctly implemented.

The LogsActivity trait is properly used within the class and will enable activity logging for the TaxRate model.

packages/core/src/Models/AttributeGroup.php (2)

11-11: LGTM! Import statement properly added.

The LogsActivity trait import is correctly placed and follows PSR-12 conventions.


28-28: LGTM! Trait usage correctly implemented.

The LogsActivity trait is properly used within the class and will enable activity logging for the AttributeGroup model.

packages/core/src/Models/ProductOption.php (2)

14-14: LGTM! Import statement properly added.

The LogsActivity trait import is correctly placed and follows PSR-12 conventions.


34-34: LGTM! Trait usage correctly implemented.

The LogsActivity trait is properly used within the class and will enable activity logging for the ProductOption model.

packages/table-rate-shipping/src/Models/ShippingRate.php (1)

12-12: LogsActivity trait properly integrated.

The import statement and trait usage are correctly placed and follow the existing code style. The alphabetical ordering of imports is maintained, and the trait is appropriately positioned with other trait declarations.

Also applies to: 24-24

packages/core/src/Models/CollectionGroup.php (1)

9-9: LogsActivity trait properly integrated.

The import statement and trait usage are correctly implemented. The alphabetical ordering of imports is maintained, and the trait declaration follows the established pattern.

Also applies to: 23-23

packages/table-rate-shipping/src/Models/ShippingMethod.php (1)

12-12: LogsActivity trait properly integrated.

The import and trait usage are correctly implemented with proper alphabetical ordering and positioning. The integration follows the established code style consistently.

Also applies to: 22-22

packages/core/src/Models/CustomerGroup.php (1)

12-12: LogsActivity trait properly integrated.

The import statement and trait usage are correctly implemented. The alphabetical ordering is maintained, and the trait declaration is appropriately positioned among the other trait declarations.

Also applies to: 30-30

packages/admin/src/Models/Staff.php (1)

15-15: LogsActivity trait properly integrated.

The import statement and trait usage are correctly implemented with proper alphabetical ordering. The trait integration follows the established pattern and is particularly valuable for the Staff model from an audit perspective.

Also applies to: 39-39

packages/core/src/Models/Discount.php (2)

14-14: LGTM! Import statement correctly placed.

The LogsActivity trait import is properly positioned alphabetically among other trait imports and follows the consistent namespace pattern used throughout the codebase.


39-39: LGTM! Trait usage correctly implemented.

The LogsActivity trait is properly added to the existing trait list, enabling activity logging capabilities for the Discount model as intended. This change aligns perfectly with the PR objectives to provide clients with visibility into all changes made to core models.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@glennjacobs glennjacobs merged commit 34cac16 into lunarphp:1.x Aug 14, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants