{note} You're browsing the documentation for an old version of laravel-settings. Consider upgrading your project to v2.

Contextual Settings

If you need settings based on context, let's say for a specific user, you can do that easily as well using the Rawilk\Settings\Support\Context class.

use Rawilk\Settings\Support\Context;
use Rawilk\Settings\Facades\Settings;

$userContext = new Context(['user_id' => 1]);
$user2Context = new Context(['user_id' => 2]);

Settings::context($userContext)->set('notifications', true);
Settings::context($user2Context)->set('notifications', false);

Settings::context($userContext)->isTrue('notifications'); // true
Settings::context($user2Context)->isTrue('notifications'); // false

{tip} You can put anything you want in context, as long as it's in array form.

← Previous Topic

Basic Usage

Next Topic →

Settings Helper

Caught a mistake? Suggest an edit on Github