Custom connection model
Point the model key at your own subclass to add methods, relations or traits. The facade, trait, actions and commands all resolve the model through it:
namespace App\Models;
use RoundlyConsulting\Connections\Models\Connection as BaseConnection;
class Connection extends BaseConnection
{
public function isOwner(): bool
{
return $this->meta('role') === 'owner';
}
}// config/connections.php
'model' => App\Models\Connection::class,- The replacement must be RoundlyConsulting\Connections\Models\Connection or extend it. Anything else — a missing class, a non-model, a model that isn’t a Connection — throws the toolkit’s InvalidConfigurationException naming the key; it is never silently replaced by the packaged model.
- The model reads its table from the table key unless your subclass sets $table.
- HasConnections resolves the model through a protected connectionModel() method you can override on a connectable model. The actions keep reading the model key, so point both at the same class.
- Run model:prune against your subclass when you use one.
Reporting connections with reports-for-laravel
Connections deliberately doesn’t depend on reports-for-laravel. For a report-this-connection flow, wire it in your app through a custom model — no change to this package:
// 1. Install reports in your app: composer require roundly-consulting/reports-for-laravel
// 2. Point connections at your own model: config/connections.php => 'model' => \App\Models\Connection::class
// 3. Make that model reportable:
use RoundlyConsulting\Connections\Models\Connection as BaseConnection;
use RoundlyConsulting\Reports\Contracts\Reportable;
use RoundlyConsulting\Reports\Traits\HasReports;
class Connection extends BaseConnection implements Reportable
{
use HasReports;
}
// 4. Report / moderate through the reports facade:
Reports::report($connection)->by($user)->for(Reason::Spam)->create();
$connection->hasBeenReported(); // true
$connection->isReportedBy($user); // dedupe UX
Connection::query()->mostReported(); // triage worst offendersMulti-moderator sign-off is inherited from reports → approvals. Because the wiring lives in your app, the connections runtime stays free of any reports dependency.
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.