Weave 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

A Laravel package that provides a Publishes trait to make Eloquent models publishable, along with schema blueprint helpers for adding publishing date fields to migrations. Install via Composer and apply the trait to your models.

View on GitHub
Deep Wiki
Context7

Eloquent Publishing

lemaur/eloquent-publishing is a Laravel package that adds publishing capabilities to your Eloquent models. Apply the Publishes trait to any model, add a publishing date column, and manage publish state through a clean, expressive API.

  • Publishes trait to make any Eloquent model publishable
  • Schema blueprint helpers for quick migration setup
  • Query scopes to filter published and unpublished records
  • Simple methods to publish and unpublish models
  • Zero configuration and seamless Laravel integration
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.
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox