Corepine logo Corepine Wirechat
Login
Wirechat v0.6x latest

Setting

Setting stores Wirechat-owned preferences for an owner model, usually one of your user models.

The table is one row per owner. The data column stores only values that differ from the UserSettings defaults, so default users do not need a database row.

Core fields:

Field Purpose
owner_id Owner model id.
owner_type Owner morph class.
data Nullable JSON payload for Wirechat settings.

Important Relationships

owner(): MorphTo

Returns the app model that owns the settings row.

$setting->owner

User models using InteractsWithWirechat also receive:

$user->wirechatSettings()

Settings API

Normal application code should use the DTO and manager instead of reading data directly:

use Wirechat\Wirechat\Facades\Wirechat;

$settings = Wirechat::settings($user);

if ($settings->notification_previews_enabled) {
    // Show preview text.
}

To update settings:

use Wirechat\Wirechat\Services\WirechatSettingsManager;

app(WirechatSettingsManager::class)->updateFor($user, [
    'group_message_notifications_enabled' => false,
]);

Safe customizations:

  • Add app-specific relationships or scopes to a custom Setting subclass.
  • Keep owner() and the data cast intact.
  • Keep package-owned keys compatible with Wirechat\Wirechat\Settings\UserSettings.

For the full settings API, see Settings.