PHPackages                             soarecostin/laravel-toggle-switch-fields - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. soarecostin/laravel-toggle-switch-fields

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

soarecostin/laravel-toggle-switch-fields
========================================

v0.0.1-alpha(6y ago)030MITPHPPHP &gt;=7.2.0

Since Jul 5Pushed 6y agoCompare

[ Source](https://github.com/soarecostin/laravel-toggle-switch-fields)[ Packagist](https://packagist.org/packages/soarecostin/laravel-toggle-switch-fields)[ RSS](/packages/soarecostin-laravel-toggle-switch-fields/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Laravel ToggleSwitch Fields
===========================

[](#laravel-toggleswitch-fields)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/8bd3977347b627aa284974606cf664a891934ad433ad50a65523f2d99a4a3855/68747470733a2f2f7472617669732d63692e6f72672f736f617265636f7374696e2f6c61726176656c2d746f67676c652d7377697463682d6669656c64732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/soarecostin/laravel-toggle-switch-fields)[![StyleCI](https://camo.githubusercontent.com/2b99ebaeaa56e56cffe995ea044fa352a1ac36a26fea04dc1ed3d88fd876ef38/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3139353035333136342f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/195053164)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1f22cfafb101e17f18160e68275d8cee77d9b029ce6c4b768cb9801a54c85e87/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736f617265636f7374696e2f6c61726176656c2d746f67676c652d7377697463682d6669656c64732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/soarecostin/laravel-toggle-switch-fields/?branch=master)[![Build Status](https://camo.githubusercontent.com/0f9b5f778ad71c921670b458625622088223c09f43117598fbe146d63b55a769/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736f617265636f7374696e2f6c61726176656c2d746f67676c652d7377697463682d6669656c64732f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/soarecostin/laravel-toggle-switch-fields/build-status/master)

This package allows you to quickly implement toggle switch fields logic into your Laravel Controllers. It comes with different field type support (boolean and timestamp) out of the box and allows you to add custom logic yourself. This package does not provide any implementation of Toggle Switch buttons on the front-end, but just the logic needed to make any Toggle Switch work.

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

[](#installation)

In order to install this package, just run

```
composer require soarecostin/laravel-toggle-switch-fields
```

Usage
-----

[](#usage)

### Customization

[](#customization)

You can publish the configuration file, that contains all the available checks using:

```
php artisan vendor:publish --provider=SoareCostin\LaravelToggleSwitchFields\ToggleSwitchFieldsServiceProvider
```

This will publish a `toggle_switch_fields.php` file in your config folder.

#### Available Configuration Options

[](#available-configuration-options)

The following options are available:

- Default field name - will be used as the default field name that will be toggled, for all controllers. The default value is `published`. You can overwrite this setting per each controller, as explained below, in the Controllers section

```
default_field => 'published'
```

### Controllers

[](#controllers)

For each Laravel Controller where you want to implement the toggle switch logic for some fields, add the `use Switchable` trait from this package:

```
use App\Http\Controllers\Controller;
use SoareCostin\LaravelToggleSwitchFields\Traits\Switchable;

class YourCustomController extends Controller
{
    use Switchable;
    // ...
}
```

This trait will add two functions to your controller: `switchOn` and `switchOff`

### Routes

[](#routes)

Add the following to your `routes.php` file:

```
use SoareCostin\LaravelToggleSwitchFields\Facades\ToggleSwitchFields;

ToggleSwitchFields::routes('/your-custom-url/{your-custom-route-param}', 'YourCustomController', 'your.custom.route.prefix');
```

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

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information.

License
-------

[](#license)

This library is licensed under the MIT license. Please see [License file](LICENSE.md) for more information.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

2504d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e6a3530dabd438342d60c35adbfac90091860bcdb49b3498678178fe088f38d?d=identicon)[soarecostin](/maintainers/soarecostin)

---

Top Contributors

[![soarecostin](https://avatars.githubusercontent.com/u/6401790?v=4)](https://github.com/soarecostin "soarecostin (17 commits)")

---

Tags

laraveltoggle-switches

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/soarecostin-laravel-toggle-switch-fields/health.svg)

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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