bavix / laravel-settings
Keep user settings easy.
1.1.0
2020-08-31 10:11 UTC
Requires
- php: ^7.2
- illuminate/database: ^5.5|^6.0|^7.0|^8.0
Requires (Dev)
- infection/infection: ^0.14
- orchestra/testbench: ^4.2|^5.0
- phpstan/phpstan: ^0.11
- phpunit/phpunit: ^8.4
README
laravel-settings - Keep user settings easy.
- Vendor: bavix
- Package: laravel-settings
- Version:
- PHP Version: 7.2+
- Laravel Version:
5.5
,5.6
,5.7
,5.8
,6.x
,7.x
,8.x
- Composer:
composer require bavix/laravel-settings
Usage
Add the HasSettings
, HasSetSettings
, HasGetSettings
trait and Settingable
interface to model.
use Bavix\Settings\Traits\HasSettings; use Bavix\Settings\Traits\HasSetSettings; use Bavix\Settings\Traits\HasGetSettings; use Bavix\Settings\Interfaces\Settingable; class User extends Model implements Settingable { use HasGetSettings, HasSetSettings, HasSettings; }
Checking user settings.
$user = User::first(); $user->getSetting('notify'); // null $user->getSettingBool('notify'); // null $user->getSettingBool('notify', false); // bool(false)
Let's save the settings.
(bool)$user->setSettingBool('notify', false); // bool(true) $user->getSettingBool('notify', false); // bool(false)