PHPackages                             longestdrive/laravel-user-settings - 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. longestdrive/laravel-user-settings

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

longestdrive/laravel-user-settings
==================================

Simple user settings facade for Laravel 11. Forked from Grimthorr/laravel-user-settings

11.0.1(1y ago)0751MITPHPPHP &gt;=8.2.0

Since Jan 21Pushed 11mo agoCompare

[ Source](https://github.com/longestdrive/laravel-user-settings)[ Packagist](https://packagist.org/packages/longestdrive/laravel-user-settings)[ Docs](https://github.com/longestdrive/laravel-user-settings)[ RSS](/packages/longestdrive-laravel-user-settings/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (3)Versions (25)Used By (0)

laravel-user-settings
=====================

[](#laravel-user-settings)

Simple user settings facade for Laravel 9. Settings are stored as JSON in a single database column, so you can easily add it to an existing table (`users` for example).

\*\*This is a fork from \*\* [Grimthorr/Laravel-user-settings](https://github.com/Grimthorr/laravel-user-settings). Forked to enable Laravel 9 compatibility

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

[](#installation)

1. Run `composer require longestdrive/laravel-user-settings` to include this in your project.
2. Add \[optional - package should be detected\] `'longestdrive\LaravelUserSettings\ServiceProvider'` to `providers` in `config/app.php`.

```
'providers' => array(
  // ...
  'Longestdrive\LaravelUserSettings\ServiceProvider',
),
```

3. Add `'Setting' => 'Longestdrive\LaravelUserSettings\Facade'` to `aliases` in `config/app.php`.

```
'aliases' => array(
  // ...
  'Setting' => 'Longestdrive\LaravelUserSettings\Facade',
),
```

4. Run `php artisan vendor:publish --provider="Longestdrive\LaravelUserSettings\ServiceProvider" --tag="config"` to publish the config file.
5. Modify the published configuration file located at `config/laravel-user-settings.php` to your liking.
6. Create a varchar (string) column in a table on your database to match the config file in step 5. Alternatively, use the Laravel migration included in this package to automatically create a `settings` column in the `users` table: `php artisan vendor:publish --provider="Grimthorr\LaravelUserSettings\ServiceProvider" --tag="migrations" && php artisan migrate`.

Configuration
-------------

[](#configuration)

Pop open `config/laravel-user-settings.php` to adjust package configuration. If this file doesn't exist, run `php artisan vendor:publish --provider="Longestdrive\LaravelUserSettings\ServiceProvider" --tag="config"` to create the default configuration file.

```
return array(
  'table' => 'users',
  'column' => 'settings',
  'constraint_key' => 'id',
  'default_constraint_value' => null,
  'custom_constraint' => null,
);
```

#### Table

[](#table)

Specify the table on your database that you want to use.

#### Column

[](#column)

Specify the column in the above table that you want to store the settings JSON data in.

#### Constraint key

[](#constraint-key)

Specify the index column used for the constraint - this is used to differentiate between different users, objects or models (normally id).

#### Default constraint value

[](#default-constraint-value)

Specify the default constraint value - by default this will be the current user's ID, and will be superseded by specifying a `$constraint_value` on any function call.

#### Custom constraint

[](#custom-constraint)

Specify a where clause for each query - set this if you **do not** want to access different rows (for example if your app is single-user only).

Usage
-----

[](#usage)

Use the Setting facade (`Setting::`) or the helper function (`setting()->`) to access the methods in this package. The `$constraint_value` parameter is optional on all functions; if this is not passed, the `default_constraint_value` from the config file will be used.

#### Set

[](#set)

```
Setting::set('key', 'value', $constraint_value);
setting()->set('key', 'value', $constraint_value);
```

Use `set` to change the value of a setting. If the setting does not exist, it will be created automatically. You can set multiple keys at once by passing an associative (key=&gt;value) array to the first parameter.

#### Get

[](#get)

```
Setting::get('key', 'default', $constraint_value);
setting()->get('key', 'default', $constraint_value);
setting('key', 'default', $constraint_value);
```

Use `get` to retrieve the value of a setting. The second parameter is optional and can be used to specify a default value if the setting does not exist (the default default value is `null`).

#### Forget

[](#forget)

```
Setting::forget('key', $constraint_value);
setting()->forget('key', $constraint_value);
```

Unset or delete a setting by calling `forget`.

#### Has

[](#has)

```
Setting::has('key', $constraint_value);
setting()->has('key', $constraint_value);
```

Check for the existence of a setting, returned as a boolean.

#### All

[](#all)

```
Setting::all($constraint_value);
setting()->all($constraint_value);
```

Retrieve all settings as an associative array (key=&gt;value).

#### Save

[](#save)

```
Setting::save($constraint_value);
setting()->save($constraint_value);
```

Save all changes back to the database. This will need to be called after making changes; it is not automatic.

#### Load

[](#load)

```
Setting::load($constraint_value);
setting()->load($constraint_value);
```

Reload settings from the database. This is called automatically if settings have not been loaded before being accessed or mutated.

Example
-------

[](#example)

These examples are using the default configuration.

#### Using the default constraint value

[](#using-the-default-constraint-value)

The following sets and returns the currently logged in user's setting "example".

```
// Set 'example' setting to 'hello world'
Setting::set('example', 'hello world');

// Save to database
Setting::save();

// Get the same setting
return Setting::get('example');
```

#### Specify a constraint value

[](#specify-a-constraint-value)

The following sets and returns the setting "example" for the user with id of 23.

```
// Set 'example' setting to 'hello world'
Setting::set('example', 'hello world', 23);

// Save to database
Setting::save(23);

// Get the same setting
return Setting::get('example', null, 23);
```

Finally
-------

[](#finally)

#### Contributing

[](#contributing)

Feel free to create a fork and submit a pull request if you would like to contribute.

#### Bug reports

[](#bug-reports)

Raise an issue on GitHub if you notice something broken.

#### Credits

[](#credits)

Entirely based on  - I only updated to L6

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance43

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 59.2% 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

Every ~180 days

Recently: every ~289 days

Total

20

Last Release

704d ago

Major Versions

V6.0.1 → 7.0.12021-04-09

7.0.1 → 8.0.12021-04-09

8.0.1 → 9.0.12022-12-09

9.0.1 → 10.0.12024-06-07

10.0.1 → 11.0.12024-06-07

PHP version history (4 changes)1.0.0PHP &gt;=5.4.0

V6.0.1PHP &gt;=7.2.0

9.0.1PHP &gt;=8.1.0

11.0.1PHP &gt;=8.2.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3138181?v=4)[longestdrive](/maintainers/longestdrive)[@longestdrive](https://github.com/longestdrive)

---

Top Contributors

[![Grimthorr](https://avatars.githubusercontent.com/u/5190473?v=4)](https://github.com/Grimthorr "Grimthorr (42 commits)")[![longestdrive](https://avatars.githubusercontent.com/u/3138181?v=4)](https://github.com/longestdrive "longestdrive (26 commits)")[![johannesschobel](https://avatars.githubusercontent.com/u/9431350?v=4)](https://github.com/johannesschobel "johannesschobel (2 commits)")[![balping](https://avatars.githubusercontent.com/u/5840038?v=4)](https://github.com/balping "balping (1 commits)")

### Embed Badge

![Health badge](/badges/longestdrive-laravel-user-settings/health.svg)

```
[![Health](https://phpackages.com/badges/longestdrive-laravel-user-settings/health.svg)](https://phpackages.com/packages/longestdrive-laravel-user-settings)
```

###  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)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)

PHPackages © 2026

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