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

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

At a glance

Frequently asked questions about Eloquent Publishing
How do I add publishing support to an existing Laravel Eloquent model?
Use the `Publishes` trait in your model class and update its migration with `$table->publishes()` to add the `published_at` column. No additional configuration is needed for basic functionality. For custom column names, use `$table->publishes('custom_column_name')`.
Does this package work with Laravel 10+ and PHP 8.2+?
Yes, the package officially supports Laravel 9+ and PHP 8.1+, with active development for Laravel 13 and PHP 8.5. Check the [GitHub releases](https://github.com/leMaur/eloquent-publishing/releases) for version-specific compatibility notes.
Can I query only published or unpublished records easily?
Absolutely. The package provides built-in query scopes like `onlyPublished()`, `onlyUnpublished()`, and `latestPlanned()` for filtering. These integrate seamlessly with Eloquent’s query builder for fluent syntax.
What happens if I need timezone-aware publish dates?
By default, timestamps use UTC. For timezone-aware dates, use the `publishesTz()` migration method or manually set the column’s timezone in your model. The trait itself doesn’t enforce timezones but supports custom column logic.
How do I trigger actions when a model is published or unpublished?
The package dispatches events like `Publishing`, `Published`, `Unpublishing`, and `Unpublished`. Listen to these events in your `EventServiceProvider` or via Laravel’s event system to add custom logic like notifications or auditing.
Is there a way to bulk-publish or unpublish multiple records?
Yes, you can use Eloquent’s `update()` or `each()` methods to batch-update `published_at` values. For performance, ensure your `published_at` column is indexed. The package doesn’t include bulk operations natively but works with standard Eloquent patterns.
Can I combine this with soft deletes or versioning?
The package focuses solely on publishing workflows and doesn’t include soft deletes or versioning. However, you can use it alongside Laravel’s `SoftDeletes` trait or third-party versioning packages like `spatie/laravel-activitylog` without conflicts.
What if I need to add the `published_at` column to an existing production database?
Run a new migration with `$table->timestamp('published_at')->nullable()->after('created_at')` and backfill existing records with a seeder or data update script. The package won’t alter existing data—it only adds the column for new records.
Are there any performance considerations for large datasets?
The package adds minimal overhead. Query scopes use standard Eloquent optimizations, but for large datasets, ensure the `published_at` column is indexed. Avoid complex joins in scopes if performance is critical.
What alternatives exist for Laravel model publishing?
Alternatives include `spatie/laravel-activitylog` (for auditing), `laravel-nova` (for admin panels with publishing), or custom solutions using Eloquent accessors. However, this package is lightweight and tailored specifically for publish/unpublish workflows with zero external dependencies.
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.
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed