---
title: "Configuration — Likes for Laravel | Roundly"
description: "Every config key and its default — model, table, key type, reactions, actor resolver, weights, trending and broadcasting."
url: https://roundly-consulting.com/open-source/docs/likes-for-laravel/configuration
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Likes for Laravel](https://roundly-consulting.com/open-source/docs/likes-for-laravel.md)

# Configuration

The published config/likes.php, without its comments:

```php
use RoundlyConsulting\Likes\Models\Like;

return [
    'model' => Like::class,
    'table' => env('LIKES_TABLE', 'likes'),
    'key_type' => env('LIKES_KEY_TYPE', 'bigint'),
    'reactions' => ['like'],
    'default_reaction' => env('LIKES_DEFAULT_REACTION', 'like'),
    'actor_resolver' => null,
    'facade_alias' => env('LIKES_FACADE_ALIAS', 'Likes'),

    'weights' => [
        // 'like' => 1,
        // 'love' => 4,
    ],
    'default_weight' => 1,

    'trending' => [
        'window' => '7 days',
        'recent_multiplier' => 3,
        'driver_expressions' => [
            // 'pgsql' => 'SUM(1 / POWER(EXTRACT(EPOCH FROM (NOW() - created_at)) / 3600 + 2, 1.8))',
        ],
    ],

    'broadcast' => [
        'enabled' => env('LIKES_BROADCAST', false),
        'channel_prefix' => 'likes',
        'channel_type' => 'private',
    ],
];
```

## Every key

| Key | Default | Env | Purpose |
| --- | --- | --- | --- |
| `model` | Like::class | — | Eloquent model that stores likes. Must be the package model or extend it; any other class throws InvalidConfigurationException. A subclass’s own $table wins over table, for writes and every scope. |
| `table` | likes | `LIKES_TABLE` | Likes table — read by the migration, the model and every scope. A string; a blank value (LIKES\_TABLE=) is not set and takes the default. |
| `key_type` | bigint | `LIKES_KEY_TYPE` | Key type of the actor and likeable morph columns — bigint, uuid or ulid. Set it before migrating when your actors or likeables use UUID/ULID keys; any other value throws InvalidConfigurationException. |
| `reactions` | \['like'\] | — | Allowlist of reaction types — a non-empty list of strings. Any other type throws InvalidReactionTypeException. |
| `default_reaction` | like | `LIKES_DEFAULT_REACTION` | Reaction used when none is given. Must be listed in reactions. |
| `actor_resolver` | null | — | How the facade resolves the actor: null uses auth()->user(); or a callable / invokable class-string returning a model or null. A value that doesn’t resolve to a callable throws. |
| `facade_alias` | Likes | `LIKES_FACADE_ALIAS` | Global class alias for the Likes facade. null or false/0/off/no (LIKES\_FACADE\_ALIAS=false) skips the alias; a blank value is not set, so Likes is registered. |
| `weights` | \[\] | — | Per-reaction weights for orderByLikeScore() and orderByTrending(). Empty means the score is the raw count. Every weight must be an int or a float. |
| `default_weight` | 1 | — | Weight of any reaction not listed in weights (applies once weights is non-empty); an int or a float. |
| `trending.window` | 7 days | — | Recency window used by orderByTrending(); a string (blank takes the default). |
| `trending.recent_multiplier` | 3 | — | How much likes inside the window outweigh all-time activity (int or float; anything else throws). |
| `trending.driver_expressions` | \[\] | — | Optional raw SQL aggregate per database driver (sqlite, mysql, pgsql, …) that replaces the trending score for queries on a connection of that driver. Every ? is bound to the window cut-off. A non-string expression throws; a blank one is not set, so the portable score applies. |
| `broadcast.enabled` | false | `LIKES_BROADCAST` | Opt-in broadcasting of Liked, Unliked and ReactionChanged. Env strings such as true/1/on and false/0/off are understood; anything else throws InvalidConfigurationException. |
| `broadcast.channel_prefix` | likes | — | Channel name prefix, e.g. likes.App.Models.Post.42; a string (blank takes the default). |
| `broadcast.channel_type` | private | — | private, public or presence; anything else throws. |

A key that is not set — absent, null, or blank like a host’s LIKES\_TABLE= — takes its default (a blank driver expression: the portable score). A value that is set must fit: a non-string table, default\_reaction, trending.window or broadcast.channel\_prefix, a reactions list that is empty or holds a non-string, a non-numeric weight, multiplier or default weight, a non-string driver expression or a broadcast.channel\_type typo — it no longer reads as private — throws InvalidConfigurationException instead of falling back or being dropped.

## Environment

The deployment-sensitive keys are env-backed, so you rarely need to publish the config at all:

```bash
LIKES_TABLE=likes
LIKES_KEY_TYPE=bigint
LIKES_DEFAULT_REACTION=like
LIKES_FACADE_ALIAS=Likes
LIKES_BROADCAST=false
```

## Rules worth knowing

- table and key\_type are read when the migration runs — set them before you migrate.
- default\_reaction must be one of reactions; otherwise every call without an explicit type throws InvalidReactionTypeException.
- A closure in actor\_resolver works, but Laravel can’t cache config that contains closures — prefer an invokable class-string with php artisan config:cache.
- Broadcasting is off until broadcast.enabled is true; the events are dispatched to your listeners either way.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/likes-for-laravel.md)
