The Report model
Each report is a Report model with status cast to the Status enum and resolved_at cast to a datetime:
$report->status; // Status enum
$report->reason; // 'spam' — the reason slug
$report->description; // ?string — the reporter's description
$report->guest_identifier; // ?string — set for guest reports
$report->resolution_note; // ?string — the moderator's note
$report->resolved_at; // ?CarbonRelations
Three MorphTo relations point at the models involved:
$report->reporter; // ?Model — null for guest and anonymous reports
$report->reported; // ?Model — the reported subject
$report->resolvedBy; // ?Model — the moderator who settled itSoft deletes
Report uses soft deletes: delete() keeps the row and timestamps deleted_at. Use withTrashed(), restore() and forceDelete() as usual:
$report->delete(); // keeps the row, sets deleted_at
Report::withTrashed()->find($id);
$report->restore();
$report->forceDelete(); // removes the row for goodUsing your own model
Point model at a subclass of Report to add behaviour — Report is deliberately not final:
namespace App\Models;
use RoundlyConsulting\Reports\Models\Report as BaseReport;
class Report extends BaseReport
{
// your own relations, scopes and casts
}
// config/reports.php
'model' => App\Models\Report::class,The traits, actions and commands all resolve the model through config, so your subclass is what they create and query. A configured class that isn’t Report or a subclass of it throws the toolkit’s InvalidConfigurationException naming the key — it is never silently replaced by the packaged Report.
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.