open-southeners/laravel-model-status
Lightweight Laravel model status handling using native PHP enums—no extra tables needed. Define a status enum, attach it via a PHP attribute, and use a trait for helpers like setStatus, setStatusWhen, hasStatus, and optional status events.
ModelStatus interface and Statusable trait encourage explicit status modeling, which is valuable for business logic separation (e.g., PostStatus::Published vs. UserStatus::Active).Post::whereStatus(PostStatus::Published)) via the HasStatuses trait.Archived status) require backward-compatible handling (e.g., default values or deprecated cases).Draft → Published) should be unit-tested for business logic correctness, but the package itself lacks built-in validation hooks.Draft → Hidden bypass Published?)PostStatus::Published & Reviewed)? The package appears single-status focused.spatie/laravel-activitylog) may be needed.Published triggers a webhook)? The package provides hooks via traits but may require extension.JsonSerializable implementation.assertEquals(PostStatus::Published, $post->status)).Post) to validate the enum/trait pattern.ModelStatuses attribute to auto-discover statuses (reduces manual configuration).User, Order) with shared status enums where applicable.is_published) with the package’s standardized approach.Post::saved() to sync old is_published to new status).HasStatuses trait and [ModelStatuses] attribute in one PR per model.dd($model->status) for quick inspection.ModelStatus interface on enums.optimistic locking).if (!$model->status->isValid()) throw new InvalidStatusException()).json_encode($model->toArray()).PascalCase for statuses).Published can be Archived").How can I help you explore Laravel packages today?