NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
Reports for Laravel

Database schema & key types

One table backs the package. Its name comes from the table config key:

ColumnTypeNotes
idbigintAuto-incrementing primary key, whatever key_type says.
reporter_type / reporter_idnullable morphThe reporter — null for guest and anonymous reports.
reported_type / reported_idnullable morphThe reported subject.
resolved_by_type / resolved_by_idnullable morphThe moderator who settled the report — null for system actions.
statusstring, indexedStatus value, default pending.
reasonstring, indexedThe reason slug.
descriptiontext, nullableThe reporter’s description.
resolution_notetext, nullableThe moderator’s note.
guest_identifierstring, nullable, indexedHashed IP or email used to dedupe guest reports.
resolved_attimestamp, nullableWhen the report was resolved or rejected.
created_at / updated_attimestampsStandard Eloquent timestamps.
deleted_attimestamp, nullableSoft 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_typeMorph id columnsUse when your models use
bigintbigintAuto-incrementing integer keys (the default).
uuiduuidUUID primary keys (HasUuids).
ulidchar(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=uuid
use 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 crypto

By 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.