PHPackages                             3neti/laravel-model-channel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. 3neti/laravel-model-channel

ActiveLibrary[Database &amp; ORM](/categories/database)

3neti/laravel-model-channel
===========================

A package to enable assigning communication channels to Eloquent models.

v1.1.0(2mo ago)036↓80%2proprietaryPHPPHP ^8.2

Since Mar 26Pushed 2mo agoCompare

[ Source](https://github.com/3neti/laravel-model-channel)[ Packagist](https://packagist.org/packages/3neti/laravel-model-channel)[ RSS](/packages/3neti-laravel-model-channel/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (9)Versions (4)Used By (2)

laravel-model-channel
=====================

[](#laravel-model-channel)

A schema-light Laravel capability package for attaching delivery and communication channels to Eloquent models through a polymorphic `channels` table.

Why this package exists
-----------------------

[](#why-this-package-exists)

This package lets a model expose capabilities like mobile or webhook delivery without requiring host apps to add direct columns such as `users.mobile` or `users.webhook`.

Channels are stored in the package-owned morph table, keeping your application schema clean and flexible.

---

Installation
------------

[](#installation)

```
composer require 3neti/laravel-model-channel
php artisan migrate
```

---

Supported Channel Types
-----------------------

[](#supported-channel-types)

Out of the box, the package supports:

- `mobile` (normalized to E.164 without `+`)
- `webhook` (validated URL)
- `telegram` (numeric ID)
- `whatsapp` (phone-based)
- `viber` (phone-based)

All channels are validated via enum-backed rules.

---

Basic usage
-----------

[](#basic-usage)

```
use Illuminate\Database\Eloquent\Model;
use LBHurtado\ModelChannel\Contracts\HasMobileChannel;
use LBHurtado\ModelChannel\Contracts\HasWebhookChannel;
use LBHurtado\ModelChannel\Traits\HasChannels;

class User extends Model implements HasMobileChannel, HasWebhookChannel
{
    use HasChannels;
}
```

---

Explicit capability API
-----------------------

[](#explicit-capability-api)

### Mobile

[](#mobile)

```
$user->setMobileChannel('09171234567');

$user->getMobileChannel(); // 639171234567
$user->hasMobileChannel(); // true
```

Accepted formats:

```
$user->setMobileChannel('09171234567');
$user->setMobileChannel('0917 123 4567');
$user->setMobileChannel('639171234567');
$user->setMobileChannel('+639171234567');
$user->setMobileChannel('+63 (917) 123-4567');
```

All normalize to:

```
639171234567
```

---

### Webhook

[](#webhook)

```
$user->setWebhookChannel('https://example.com/webhook');

$user->getWebhookChannel(); // https://example.com/webhook
$user->hasWebhookChannel(); // true
```

---

Generic API
-----------

[](#generic-api)

```
$user->setChannel('webhook', 'https://example.com/webhook');

$user->getChannel('webhook');
$user->hasChannel('webhook');
```

Using enum:

```
use LBHurtado\ModelChannel\Enums\Channel;

$user->setChannel(Channel::WEBHOOK, 'https://example.com/webhook');
```

Delete a channel:

```
$user->setChannel(Channel::WEBHOOK, null);
$user->setChannel(Channel::WEBHOOK, '');
```

---

Magic properties (backward compatibility)
-----------------------------------------

[](#magic-properties-backward-compatibility)

```
$user->mobile = '09171234567';

$user->mobile;              // 639171234567
$user->getMobileChannel();  // 639171234567
```

---

Additional helpers
------------------

[](#additional-helpers)

### Telegram

[](#telegram)

```
$user->setTelegramChannel('123456789');
$user->getTelegramChannel();
$user->hasTelegramChannel();
```

### WhatsApp

[](#whatsapp)

```
$user->setWhatsappChannel('09171234567');
$user->getWhatsappChannel();
$user->hasWhatsappChannel();
```

### Viber

[](#viber)

```
$user->setViberChannel('09171234567');
$user->getViberChannel();
$user->hasViberChannel();
```

---

Finders
-------

[](#finders)

```
User::findByMobile('09171234567');
User::findByWebhook('https://example.com/webhook');
User::findByChannel('telegram', '123456789');
```

Mobile finder supports multiple formats.

---

Performance &amp; Caching
-------------------------

[](#performance--caching)

### Database Indexing (Recommended)

[](#database-indexing-recommended)

For optimal performance, especially for `findByMobile()` and `findByChannel()`, add indexes:

```
$table->index(['name', 'value']);
$table->index(['model_type', 'model_id', 'name']);
```

---

### Lookup Caching (Optional)

[](#lookup-caching-optional)

Caching is designed for **finder methods only**, not accessor reads.

Supported cached operations:

- `findByMobile()`
- `findByWebhook()`
- `findByChannel()` (for configured channels)

Example config:

```
'cache' => [
    'enabled' => true,
    'ttl' => 600,
    'channels' => ['mobile', 'webhook'],
]
```

---

### Cache Behavior

[](#cache-behavior)

- caches **model IDs only** (not full models)
- caches **misses** to prevent repeated DB queries
- automatically **invalidates on update or delete**
- does **NOT cache accessor methods** like `getMobileChannel()`

---

External package integration
----------------------------

[](#external-package-integration)

```
use LBHurtado\ModelChannel\Contracts\HasMobileChannel;

function sendOtp(HasMobileChannel $user)
{
    $mobile = $user->getMobileChannel();
}
```

---

Storage model
-------------

[](#storage-model)

No schema changes required.

All data is stored in the polymorphic `channels` table.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance86

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Total

3

Last Release

73d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/586e1ed70140038e6348728222adbcf68bfc4455b1f94a4f8bcbe57917a63d57?d=identicon)[3neti](/maintainers/3neti)

---

Top Contributors

[![3neti](https://avatars.githubusercontent.com/u/89447696?v=4)](https://github.com/3neti "3neti (7 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/3neti-laravel-model-channel/health.svg)

```
[![Health](https://phpackages.com/badges/3neti-laravel-model-channel/health.svg)](https://phpackages.com/packages/3neti-laravel-model-channel)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.6k](/packages/larastan-larastan)[laravel/ai

The official AI SDK for Laravel.

9782.1M162](/packages/laravel-ai)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M153](/packages/spatie-laravel-health)[watson/validating

Eloquent model validating trait.

9733.4M53](/packages/watson-validating)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

438834.4k1](/packages/clickbar-laravel-magellan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
