PHPackages                             sfolador/laravel-eloquent-toggle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. sfolador/laravel-eloquent-toggle

ActiveLibrary[Database &amp; ORM](/categories/database)

sfolador/laravel-eloquent-toggle
================================

Add toggles to eloquent models

0.1(3y ago)32[4 PRs](https://github.com/sfolador/laravel-eloquent-toggle/pulls)MITPHPPHP ^8.2CI passing

Since Dec 15Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/sfolador/laravel-eloquent-toggle)[ Packagist](https://packagist.org/packages/sfolador/laravel-eloquent-toggle)[ Docs](https://github.com/sfolador/laravel-eloquent-toggle)[ RSS](/packages/sfolador-laravel-eloquent-toggle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (6)Used By (0)

[![Laravel Eloquent Toggle](https://camo.githubusercontent.com/a5bfea08834d745dd2ca29f885887189ad4ee9bf00caeea72945e1e33375de2b/68747470733a2f2f73666f6c61646f722d6769746875622e73332e65752d736f7574682d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d656c6f7175656e742d746f67676c652e706e673f743d31)](https://camo.githubusercontent.com/a5bfea08834d745dd2ca29f885887189ad4ee9bf00caeea72945e1e33375de2b/68747470733a2f2f73666f6c61646f722d6769746875622e73332e65752d736f7574682d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d656c6f7175656e742d746f67676c652e706e673f743d31)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8871986f2c37aebe60f89b926659d08fefd81d6e07d56a11fca78462a848b0d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73666f6c61646f722f6c61726176656c2d656c6f7175656e742d746f67676c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sfolador/laravel-eloquent-toggle)[![GitHub Tests Action Status](https://camo.githubusercontent.com/26c0f4c3988e5edededc921a020b0722c50166abcd5d4404134eea3245cf284f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73666f6c61646f722f6c61726176656c2d656c6f7175656e742d746f67676c652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e)](https://img.shields.io/github/actions/workflow/status/sfolador/laravel-eloquent-toggle/run-tests.yml?branch=main)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/dba4f4986f5cbceda4c32a1772b144968ee1f1f1ffc95d2199f43cb86454cf9f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73666f6c61646f722f6c61726176656c2d656c6f7175656e742d746f67676c652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65)](https://img.shields.io/github/actions/workflow/status/sfolador/laravel-eloquent-toggle/fix-php-code-style-issues.yml?branch=main)[![Total Downloads](https://camo.githubusercontent.com/8342bde41fa071b108aeff4b76e067ce13a74abe9d8d4c5e5f09cbc0aaa332e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73666f6c61646f722f6c61726176656c2d656c6f7175656e742d746f67676c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sfolador/laravel-eloquent-toggle)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require sfolador/laravel-eloquent-toggle
```

Usage
-----

[](#usage)

To use a *toggle* just use casts on your model:

```
use Illuminate\Database\Eloquent\Model;
use Sfolador\LaravelEloquentToggle\Casts\Boolean;

class User extends Model
{
    protected $casts = [
        'active' => Boolean::class,
    ];
    ...
}
```

then you can use it like this:

```
$user = new User();
$user->active = true;

$user->active->toggle(); // false

$isActive = $user->active->value(); // false
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [sfolador](https://github.com/sfolador)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance59

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1245d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/54c6b8884e3bd4e86d26de024ca07094728adc7db2a8a483538222121b00f9f1?d=identicon)[sfolador](/maintainers/sfolador)

---

Top Contributors

[![sfolador](https://avatars.githubusercontent.com/u/36632?v=4)](https://github.com/sfolador "sfolador (28 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (18 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (13 commits)")

---

Tags

laravelsfoladorlaravel-eloquent-toggle

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sfolador-laravel-eloquent-toggle/health.svg)

```
[![Health](https://phpackages.com/badges/sfolador-laravel-eloquent-toggle/health.svg)](https://phpackages.com/packages/sfolador-laravel-eloquent-toggle)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[spatie/laravel-sql-commenter

Add comments to SQL queries made by Laravel

1931.4M1](/packages/spatie-laravel-sql-commenter)[spatie/laravel-deleted-models

Automatically copy deleted records to a separate table

409109.8k4](/packages/spatie-laravel-deleted-models)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

203330.1k2](/packages/wnx-laravel-backup-restore)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
