Download the PHP package bernskiold/laravel-activatable without Composer

On this page you can find all versions of the php package bernskiold/laravel-activatable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-activatable

Activate and deactivate Eloquent models, the easy way

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Almost every app has models that can be turned on and off — users, products, feature flags, integrations. This package gives those models a clean active/inactive state, so you stop re-writing the same is_active boolean, the same scopes, and the same factory states in every project.

Add one trait, add one column, and you're done. Everything else — scopes, events, factory states, an optional "when was this turned off?" timestamp — is there when you want it and out of the way when you don't.

Why you'll like it

Installation

You can install the package via Composer:

If you'd like to change the column name, the default state, or enable the deactivation timestamp globally, publish the config:

Schema

Add the boolean column with the activatable() blueprint macro:

Both schema macros return the column definition, so you can keep chaining:

Usage

Add the trait to your model:

New records are active by default. From there:

Calling activate() / deactivate() on a model that is already in the requested state does nothing at all — no query is run and no event is dispatched.

Need to change the state without firing events (and without touching the model's own saving/saved events)? Reach for the quiet variants:

Events

activate() and deactivate() dispatch events only when the state actually changes. Each event exposes the $model that changed:

Tracking when a model was deactivated

Sometimes "is it off?" isn't enough — you want to know when it was switched off. Opt a model into an inactivated_at timestamp and the package keeps it in sync: it's set on deactivation and cleared again on activation.

Add the column with the inactivatedAt() macro (or enable it for every model via the track_inactivated_at config option):

Factory states

Add the factory trait for expressive active() / inactive() states. They respect the model's column (and the deactivation timestamp, if it tracks one):

A different column name

Override the column globally in config/activatable.php, or per model with a constant:

Type-hinting

The trait implements the Bernskiold\LaravelActivatable\Contracts\Activatable interface, so you can type-hint against any activatable model:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see the License File for more information.


All versions of laravel-activatable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^11.0 || ^12.0 || ^13.0
illuminate/database Version ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^11.0 || ^12.0 || ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bernskiold/laravel-activatable contains the following files

Loading the files please wait ...