Skip to content

v1.5.0

Latest
Compare
Choose a tag to compare
@thefeqy thefeqy released this 04 Mar 14:54
· 2 commits to main since this release

[v1.5.0] - 2025-03-04

New Features

  • Status Casting (StatusCast)

    • The status field is now automatically cast to a Status object.
    • Allows method calls like $model->status->isActive() and $model->status->isInactive().
    • Ensures better type safety when working with statuses.
  • Cascade Deactivation

    • When a model is deactivated, related models can also be automatically deactivated.
    • Introduced $cascadeDeactivate property to define related models that should also be deactivated.
    • Example:
      class Category extends Model
      {
          use HasActiveScope;
      
          protected array $cascadeDeactivate = ['products'];
      
          public function products()
          {
              return $this->hasMany(Product::class);
          }
      }
    • Calling $category->deactivate(); will also deactivate all associated products.

Upgrade Guide

To update to v1.5.0, run:

composer update thefeqy/laravel-model-status

Full Changelog: v1.4.0...v1.5.0