published_first_at for chronological ordering, which is ideal for content-heavy applications (e.g., blogs, news sites, marketing pages). This reduces boilerplate and enforces consistency across models.publishable() migration macro simplifies schema changes, while the trait adds publishable behavior without requiring base class inheritance.published(), draft(), scheduled()) streamline filtering, reducing manual query complexity. The published_first_at field enables efficient sorting and caching strategies.SoftDeletes, though explicit handling is needed to avoid conflicts (e.g., a soft-deleted record cannot be unpublished).publishable() macro adds only 3 columns (status, published_first_at, published_at), requiring no complex refactoring.laravel-nova-publishable extension (if used) adds Nova-specific tooling.published, unpublished) to trigger workflows like notifications or cache invalidation.published_first_at for sorting may need database indexing to avoid performance degradation.scheduled posts? Does the package account for Laravel’s config('app.timezone'), or will we need custom logic?tags:clear or similar mechanisms.publishable() interact with SoftDeletes? Can a deleted record be unpublished, or should it be treated as permanently hidden?published_first_at and state fields without downtime? Will we use a data migration or a separate script??status=published) or custom endpoints?activitylog package or a custom solution?laravel-nova-publishable for admin UI consistency).Post, Article, Product).Post) to test:
publishable() to its migration.PublishableTrait to the model.published(), draft(), etc.).BlogPost, NewsArticle).Product, Event) if needed.publishable() macro in migrations.$table->string('status')->default('draft');
$table->timestamp('published_first_at')->nullable();
$table->timestamp('published_at')->nullable()->after('published_first_at');
published_first_at (e.g., set to created_at for existing published records).status and published_first_at are indexed for performance:
$table->index('status');
$table->index('published_first_at');
assertPublished(), assertScheduled()).// API Controller
public function index(Request $request)
{
$status = $request->query('status', 'published');
return Post::query()->$status()->get();
}
cache()->tags(['posts'])->remember()) to invalidate caches on state changes.composer.json:
"require": {
"novius/laravel-publishable": "^3.0"
}
composer require novius/laravel-publishable
php artisan vendor:publish --provider="Novius\Publishable\LaravelPublishableServiceProvider" --tag=lang
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Novius\Publishable\PublishableTrait;
class Post extends Model
{
use PublishableTrait;
protected $
How can I help you explore Laravel packages today?