sfolador / laravel-eloquent-toggle
Add toggles to eloquent models
0.1
2022-12-15 21:24 UTC
Requires
- php: ^8.2
- illuminate/contracts: ^9.0
- nesbot/carbon: ^2.64
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
README
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.