PHPackages                             fefo-p/laravel-user-preferences - 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. fefo-p/laravel-user-preferences

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

fefo-p/laravel-user-preferences
===============================

A package for Laravel to store user preferences for your project.

1.0.0(4y ago)018MITPHPPHP ^8.0

Since May 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/fefo-p/laravel-user-preferences)[ Packagist](https://packagist.org/packages/fefo-p/laravel-user-preferences)[ RSS](/packages/fefo-p-laravel-user-preferences/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Laravel User Preferences
========================

[](#laravel-user-preferences)

#### Forked from [RobTrehy/LaravelUserPreferences](https://github.com/RobTrehy/LaravelUserPreferences)

[](#forked-from-robtrehylaraveluserpreferences)

[![](https://camo.githubusercontent.com/7176337f55bd53a7380786a3e9d4688454ac3c53df7486c2e5886a80b87c8437/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f4665666f502f4c61726176656c55736572507265666572656e6365732f556e697425323054657374733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/7176337f55bd53a7380786a3e9d4688454ac3c53df7486c2e5886a80b87c8437/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f4665666f502f4c61726176656c55736572507265666572656e6365732f556e697425323054657374733f7374796c653d666c61742d737175617265)[![](https://camo.githubusercontent.com/15273fd7ae883839d8ba307a3a77c4afcc71793307a3994733f5f87b3320a94b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4665666f502f4c61726176656c55736572507265666572656e6365733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/15273fd7ae883839d8ba307a3a77c4afcc71793307a3994733f5f87b3320a94b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4665666f502f4c61726176656c55736572507265666572656e6365733f7374796c653d666c61742d737175617265)[![](https://camo.githubusercontent.com/2d3e01a6fb5abc5e97c8b275b1610a2e76b95d401fe2f5c4df3a8246523f64c3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f4665666f502f4c61726176656c55736572507265666572656e6365733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/2d3e01a6fb5abc5e97c8b275b1610a2e76b95d401fe2f5c4df3a8246523f64c3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f4665666f502f4c61726176656c55736572507265666572656e6365733f7374796c653d666c61742d737175617265)[![](https://camo.githubusercontent.com/6c8ccad3831416862be354c771a178ed6db6431ffde6639ffeebf5261291643a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6665666f2d702f6c61726176656c2d757365722d707265666572656e6365733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/6c8ccad3831416862be354c771a178ed6db6431ffde6639ffeebf5261291643a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6665666f2d702f6c61726176656c2d757365722d707265666572656e6365733f7374796c653d666c61742d737175617265)[![](https://camo.githubusercontent.com/8afee369934e92282c29d2dd4311da556d0de83e93ea89dc3364722d18640095/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6665666f2d702f6c61726176656c2d757365722d707265666572656e6365733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/8afee369934e92282c29d2dd4311da556d0de83e93ea89dc3364722d18640095/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6665666f2d702f6c61726176656c2d757365722d707265666572656e6365733f7374796c653d666c61742d737175617265)

This is a package for Laravel that can be used to store and access preferences of the currently authenticated user. The preferences are stored as JSON in a single database column. The default configuration stores this alongside the user record in the `users` table.

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

[](#installation)

1. Run `composer require fefo-p/laravel-user-preferences` to include this in your project.
2. Publish the config file with the following command ```
    php artisan vendor:publish --provider="FefoP\LaravelUserPreferences\UserPreferencesServiceProvider" --tag="config"

    ```
3. Modify the published configuration file to your requirements. The file is located at `config/user-preferences.php`.
4. Add the `preferences` column to the database. A migration file is included, just run the following command ```
    php artisan vendor:publish --provider="FefoP\LaravelUserPreferences\UserPreferencesServiceProvider" --tag="migrations" && php artisan migrate

    ```

    This will add the column defined in your configuration file to the table defined in your configuration file.

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

[](#configuration)

Open `config/user-preferences.php` to adjust the packages configuration.

If this file doesn't exist, run `php artisan vendor:public --provider="FefoP\LaravelUserPreferences\UserPreferencesServiceProvider" --tag="config"`to create the default configuration file.

Set `table`, `column`, and `primary_key` to match your requirements. `primary_key` should be the users id.

In the `defaults` array you can set your default values for user preferences.

#### Example configuration

[](#example-configuration)

```
    'database' => [
        'table' => 'users',
        'column' => 'preferences',
        'primary_key' => 'id'
    ],
    'defaults' => [
        'theme' => 'blue',
        'show_welcome' => true
    ]
```

Usage
-----

[](#usage)

### Set a preference

[](#set-a-preference)

Use this method to set a preference for the **currently authenticated user**

```
UserPreferences::set(string [setting], [value]);
```

If a default preference value is set in the config file, the new value must match the type of the default value.

If no default value exists, any value type can be saved. If the default value type is not matched `UserPreferences::save()` will return an `InvalidArgumentException`.

### Reset all default preferences

[](#reset-all-default-preferences)

Use this method to reset the **currently authenticated user** to the default preferences found in the config file.

```
UserPreferences::setDefaultPreferences();
```

> Note: This will not adjust user preferences that do not contain a default value in the config file.

### Reset a specific default preference

[](#reset-a-specific-default-preference)

Use this method to reset a single preference, for the **currently authenticated user**, to the default value found in your config file, if it exists. If no default value is set in the config file, the preference will be removed from the **currently authenticated user**'s record.

```
UserPreferences::reset(string [setting]);
```

This method will return `true` if a default value was set from the config file. If no default value was found, this method will return `false`

### Get a preference

[](#get-a-preference)

Use this method to get the value of a preference for the **currently authenticated user**.

```
UserPreferences::get(string [setting]);
```

### Get all preferences

[](#get-all-preferences)

Use this method to get all of the **currently authenticated user**'s preferences

```
UserPreferences::all()
```

### Check if a user has a specific preference

[](#check-if-a-user-has-a-specific-preference)

To check if the **currently authenticated user** has a specific preference set, you can call

```
UserPreferences::has(string [setting]);
```

This will return `true` if a value was found, `false` if not.

### Save a preference

[](#save-a-preference)

All preferences are saved automatically when `UserPreferences::set();` is called.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review our [security policy](.github/SECURITY.md) on how to report security vulnerabilities.

License
-------

[](#license)

This Laravel package is free software distributed under the terms of the MIT license. See [LICENSE](LICENSE)

Local testing of this package
-----------------------------

[](#local-testing-of-this-package)

Add the following to `composer.json`

```
    "repositories": [
        {
            "type": "path",
            "url": "relative_path_to_package_sources"
        }
    ]
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

1819d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/184b78ccfd25d82a003b8aa5b8b9ae6205c2a4a4069c34beeac0e4a4986bbdc1?d=identicon)[fefo-p](/maintainers/fefo-p)

---

Top Contributors

[![fefo-p](https://avatars.githubusercontent.com/u/42467872?v=4)](https://github.com/fefo-p "fefo-p (2 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/fefo-p-laravel-user-preferences/health.svg)

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

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)[ronasit/laravel-helpers

Provided helpers function and some helper class.

1475.7k13](/packages/ronasit-laravel-helpers)[boomcms/boom-core

Core classes for BoomCMS

193.0k6](/packages/boomcms-boom-core)

PHPackages © 2026

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