Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Eloquent Publishing Laravel Package

lemaur/eloquent-publishing

Add publishing support to Laravel Eloquent models with a simple trait. Manage publish dates, query scopes and helpers, plus custom migration blueprint methods to quickly add publishing columns and build publishable content workflows.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Laravel-Native Integration: The package leverages Laravel’s Eloquent ORM and Schema Builder, ensuring seamless compatibility with existing Laravel applications. The trait-based design (Publishes) aligns with Laravel’s conventions (e.g., traits for reusable model behavior).
    • Domain-Specific Abstractions: Provides clear, business-logic methods (publish(), unpublish(), isPublished(), etc.), reducing boilerplate and improving readability for content lifecycle management (e.g., scheduled posts, drafts, or archiving).
    • Query Scoping: Adds powerful query builders (onlyPublished(), latestPlanned(), etc.), enabling efficient filtering and sorting without manual SQL or complex Eloquent logic.
    • Events: Dispatches events (publishing, published, etc.), allowing for decoupled side effects (e.g., notifications, analytics, or workflow triggers).
    • Schema Utilities: Includes migration helpers ($table->publishes()), standardizing database schema changes across models.
  • Cons:

    • Limited Flexibility for Complex Workflows: The package assumes a binary "published/unpublished" state with optional future-dated publishing. For multi-state workflows (e.g., "draft → reviewed → published → archived"), additional customization or extension would be required.
    • No Soft Deletes Integration: Lacks built-in support for Laravel’s SoftDeletes trait, which could conflict with unpublish() logic if both are used.
    • Time Zone Handling: While publishesTz() supports timezone-aware timestamps, the default behavior may not align with applications requiring strict timezone controls (e.g., global audiences).

Integration Feasibility

  • Low-Coupling Design: The trait and migration helpers are self-contained, requiring minimal changes to existing models or controllers. Integration can be incremental (e.g., start with one model type).
  • Backward Compatibility: Supports Laravel 11+ and PHP 8.2+, but drops support for older versions (e.g., Laravel 10/PHP 8.1). This is a blocker for legacy systems.
  • Database Schema Impact:
    • Adds a nullable published_at column (or custom-named equivalent) to tables. This is non-destructive but requires migration planning.
    • No schema validation for existing columns, so manual checks may be needed during adoption.

Technical Risk

  • Migration Risks:
    • Downtime: Schema changes (adding/dropping columns) may require database locks or careful rollout strategies in production.
    • Data Loss: Dropping existing published_at columns (via dropPublishes()) could inadvertently remove critical data if not tested thoroughly.
  • Behavioral Risks:
    • Event Side Effects: Events like published could trigger unintended actions (e.g., sending emails or updating caches) if not properly guarded.
    • Time-Based Logic: Future-dated publishing (isPlanned()) relies on server time, which may not sync with user expectations (e.g., timezone offsets or daylight saving).
  • Testing Gaps:
    • Limited test coverage for edge cases (e.g., concurrent publishes, invalid datetime inputs).
    • No explicit documentation on handling edge cases like NULL timestamps or time manipulation.

Key Questions for TPM

  1. Stack Compatibility:
    • Is the application using Laravel 11+ and PHP 8.2+? If not, what’s the upgrade path?
    • Are there existing published_at columns in tables? How will they be handled during migration?
  2. Workflow Requirements:
    • Does the application need multi-state workflows (e.g., beyond "published/unpublished")? If so, how will this package be extended?
    • Are there soft delete requirements? How will unpublish() interact with SoftDeletes?
  3. Performance:
    • Will query scopes (onlyPublished()) impact performance for large datasets? Are indexes needed on published_at?
    • How will future-dated publishing affect query caching (e.g., Redis) or background jobs?
  4. Observability:
    • Are events (published, unpublished) critical for auditing? How will they be logged/monitored?
    • Are there SLA requirements for publish/unpublish operations (e.g., latency, retries)?
  5. Customization:
    • Is the default published_at column name acceptable, or will custom names be required across models?
    • Are there timezone-specific requirements for publishing logic?
  6. Rollout Strategy:
    • Should this be adopted model-by-model or all-at-once? What’s the fallback plan if issues arise?
    • How will legacy data (pre-existing published_at values) be handled during migration?

Integration Approach

Stack Fit

  • Laravel Ecosystem: Perfect fit for Laravel applications using Eloquent. The package extends native Laravel features without reinventing the wheel.
  • PHP Version: Hard requirement for Laravel 11+ and PHP 8.2+. Older stacks will need upgrades.
  • Database: Works with any database supported by Laravel (MySQL, PostgreSQL, SQLite, etc.), but timezone-aware features (publishesTz()) may require database-specific configurations.
  • Testing: Compatible with Laravel’s testing tools (e.g., Pest, PHPUnit). The package includes a test suite for validation.

Migration Path

  1. Pre-Integration:
    • Audit: Identify models
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky