Database schema & key types
One table backs the package. Its name comes from the table config key:
| Column | Type | Notes |
|---|---|---|
id | bigint | Auto-incrementing primary key, whatever key_type says. |
reporter_type / reporter_id | nullable morph | The reporter — null for guest and anonymous reports. |
reported_type / reported_id | nullable morph | The reported subject. |
resolved_by_type / resolved_by_id | nullable morph | The moderator who settled the report — null for system actions. |
status | string, indexed | Status value, default pending. |
reason | string, indexed | The reason slug. |
description | text, nullable | The reporter’s description. |
resolution_note | text, nullable | The moderator’s note. |
guest_identifier | string, nullable, indexed | Hashed IP or email used to dedupe guest reports. |
resolved_at | timestamp, nullable | When the report was resolved or rejected. |
created_at / updated_at | timestamps | Standard Eloquent timestamps. |
deleted_at | timestamp, nullable | Soft deletes. |
Two composite indexes serve the hot paths: (reported_type, reported_id, status) for aggregation and threshold queries, and a dedupe index on (reported_type, reported_id, reporter_type, reporter_id) named <table>_dedupe_index.
Morph key type
key_type types the id column of all three morph pairs — reporter, reported and resolved_by. The table’s own primary key is always an auto-incrementing bigint:
| key_type | Morph id columns | Use when your models use |
|---|---|---|
bigint | bigint | Auto-incrementing integer keys (the default). |
uuid | uuid | UUID primary keys (HasUuids). |
ulid | char(26) | ULID primary keys (HasUlids). |
When key_type is uuid or ulid, your reporter, reportable and resolver models must use string primary keys. Set it before you migrate — it decides the column types:
REPORTS_KEY_TYPE=uuiduse Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Model;
use RoundlyConsulting\Reports\Traits\GivesReports;
class User extends Model
{
use GivesReports;
use HasUuids; // string primary key to match key_type = uuid
}Unset or blank reads as bigint; an unrecognised value throws the toolkit’s InvalidConfigurationException when the migration runs, rather than silently building bigint columns.
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 cryptoBy donating, you agree to our donation terms.
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.