PHPackages                             taylornetwork/setting - 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. taylornetwork/setting

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

taylornetwork/setting
=====================

A Laravel setting manager per user

2.1.0(6y ago)0170PHPPHP &gt;=7.1

Since Nov 16Pushed 6y ago2 watchersCompare

[ Source](https://github.com/taylornetwork/setting)[ Packagist](https://packagist.org/packages/taylornetwork/setting)[ RSS](/packages/taylornetwork-setting/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (12)Used By (0)

Settings for Laravel User and App
=================================

[](#settings-for-laravel-user-and-app)

This package provides an easy way to access settings for the current logged in user as well as global app settings.

**NOTE: Some features have changed in v2**

1. [Changes](#changes)
2. [About](#about)
3. [Install](#install)
4. [Usage](#usage)
    - [Available Methods](#available-methods)
    - [Classes](#classes)
    - [Facades](#facades)
    - [Helper Functions](#helpers)
5. [HasSettings Trait](#hassettings-trait)
6. [Config](#config)
7. [Alternate Configuration](#alternate-configuration)
8. [Extending](#extending)
9. [License](#license)

Changes
-------

[](#changes)

**v2.1**

- Added support for float type values.

**v2.0**

Support for app specific AND user specific settings has been added.

- Added `AppSetting` model and facade
- Added `app_setting` helper
- Added `user_setting` helper
- Renamed `Setting` model and facade to `UserSetting`
- Deprecated `setting` helper
- Renamed config key `setting_model` to `user_setting_model`

If you use the `setting` helper it will still work but will be removed, so use `user_setting` instead. The `Setting` facade has been renamed to `UserSetting` if you still have code with the `Setting` facade you can rename the alias in your `config/app.php`

```
'aliases' => [
	...
	'Setting' => TaylorNetwork\Setting\Facades\UserSetting::class,
	...
],
```

About
-----

[](#about)

This package uses Laravel's `auth` function to access the logged in user and return their setting for a given key, or a default value. Similar to the way that the `config` and `env` functions work.

When using the `HasSettings` trait it allows you to access a non-logged in user's settings.

By default if the default value is not set and a setting cannot be found, `null` is returned. The default value will also be returned if there is no logged in user.

It also includes support for app specific settings via `AppSetting`

Install
-------

[](#install)

Via Composer

```
$ composer require taylornetwork/setting
```

Run database migrations

```
$ php artisan migrate
```

---

You can optionally add the `HasSettings` trait to your user model to access settings directly.

```
namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use TaylorNetwork\Setting\Traits\HasSettings;

class User extends Authenticatable
{
   use HasSettings;

   // ...
}
```

Usage
-----

[](#usage)

*Note: the `UserSetting` and `AppSetting` classes extend `Illuminate\Database\Eloquent\Model`*

### Available Methods

[](#available-methods)

All of these methods are available when using the class or facade.

**guard($guard) \[UserSetting only\]**

This will allow you to manually set an auth guard before trying to find an active user.

```
UserSetting::guard('api')->get('key', 'defaultValue');
```

**get($key, $default = null) \[UserSetting and AppSetting\]**

Get a setting for the app/logged in user or return the default value.

```
UserSetting::get('key');

AppSetting::get('key');
```

**set($key, $value) \[UserSetting and AppSetting\]**

Creates or updates the setting for the logged in user or app.

```
UserSetting::set('someKey', 'someValue');

AppSetting::set('someKey', 'someValue');
```

### Classes

[](#classes)

UserSetting:

```
use TaylorNetwork\Setting\UserSetting;

$setting = new UserSetting;
$setting->get('someKey', 'defaultValue');
```

AppSetting:

```
use TaylorNetwork\Setting\AppSetting;

$setting = new AppSetting;
$setting->get('someKey', 'defaultValue');
```

### Facades

[](#facades)

UserSetting:

```
UserSetting::get('someKey');

UserSetting::set('someKey', 'someValue');

UserSetting::guard('api')->get('someKey', 'Default Value!');
```

AppSetting:

```
AppSetting::get('someKey');

AppSetting::set('someKey', 'someValue');
```

### Helpers

[](#helpers)

The `user_setting` and `app_setting` helper functions are aliases for the `get` method. The `user_setting` helper has an optional third parameter to pass a guard or guards.

Example:

```
// Returns the user's value or null
user_setting('key');

// Returns the app's value or null
app_setting('key');

// Returns the user's value or 'defaultValue'
user_setting('key', 'defaultValue');

// Returns the app's value or 'defaultValue'
app_setting('key', 'defaultValue');

// Returns the user's value or 'defaultValue' using the 'api' guard
user_setting('key', 'defaultValue', 'api');

// Will try and get a value from each guard in order
// If a value other than the default value is found it will immediately return it.
// If none is found after using all the guards in the array, the default value is returned.
user_setting('key', 'defaultValue', ['web', 'api']);
```

HasSettings Trait
-----------------

[](#hassettings-trait)

The `HasSettings` trait adds a `settings` relation and the following methods to your model

**setting($key, $default = null)**

This is the same as the `get` method above **BUT** can be used for any user not just one that is logged in.

**updateSetting($key, $value)**

This will create or update a setting for the specified user.

Config
------

[](#config)

If you need to change the default auth guard or user model, publish config.

```
$ php artisan vendor:publish --provider="TaylorNetwork\Setting\SettingServiceProvider" --tag=config
```

Alternate Configuration
-----------------------

[](#alternate-configuration)

You can modify the `settings` table to suit your needs, publish the migrations

```
$ php artisan vendor:publish --provider="TaylorNetwork\Setting\SettingServiceProvider" --tag=migrations
```

Be sure to update the config with appropriate `related_column` if you change it.

Extending
---------

[](#extending)

You can extend the `UserSetting` and `AppSetting` models if you need additional functionality.

```
namespace App;

use TaylorNetwork\Setting\UserSetting;

class Setting extends UserSetting
{
	// --
}
```

Be sure to update the config with the appropriate new `user_setting_model` or `app_setting_model`.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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

Every ~102 days

Recently: every ~44 days

Total

11

Last Release

2440d ago

Major Versions

1.2.1 → 2.0.02019-04-27

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

1.1.0PHP &gt;=7.0.0

1.2.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/83340094473f0bf5b2cf062bf394df221a52a30aa0e21cd0a77302977d6393ce?d=identicon)[samueljtaylor](/maintainers/samueljtaylor)

---

Top Contributors

[![samyrataylor](https://avatars.githubusercontent.com/u/15961687?v=4)](https://github.com/samyrataylor "samyrataylor (22 commits)")

### Embed Badge

![Health badge](/badges/taylornetwork-setting/health.svg)

```
[![Health](https://phpackages.com/badges/taylornetwork-setting/health.svg)](https://phpackages.com/packages/taylornetwork-setting)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M210](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M858](/packages/illuminate-pagination)[malico/laravel-nanoid

4465.3k](/packages/malico-laravel-nanoid)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[mrmarchone/laravel-auto-crud

Laravel Auto CRUD helps you streamline development and save time.

28711.8k2](/packages/mrmarchone-laravel-auto-crud)

PHPackages © 2026

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