---
title: "Custom connection model — Connections for Laravel | Roundly"
description: "Swap in your own Connection subclass via connections.model to add behaviour, and wire optional integrations such as reports-for-laravel."
url: https://roundly-consulting.com/open-source/docs/connections-for-laravel/custom-model
language: en
---

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

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

# 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:

```php
namespace App\Models;

use RoundlyConsulting\Connections\Models\Connection as BaseConnection;

class Connection extends BaseConnection
{
    public function isOwner(): bool
    {
        return $this->meta('role') === 'owner';
    }
}
```

```php
// 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:

```php
// 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 offenders
```

Multi-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 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/connections-for-laravel.md)
