sfolador/laravel-eloquent-toggle

Add toggles to eloquent models

0.1 2022-12-15 21:24 UTC

This package is auto-updated.

Last update: 2024-11-08 05:52:17 UTC


README

Laravel Eloquent Toggle

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

Installation

You can install the package via composer:

composer require sfolador/laravel-eloquent-toggle

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

composer test

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 License File for more information.