PHPackages                             inani/lazy-belongs-to-many - 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. inani/lazy-belongs-to-many

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

inani/lazy-belongs-to-many
==========================

A lightweight implementation of Laravel's BelongsToMany relationship

24312PHP

Since Nov 1Pushed 4y ago2 watchersCompare

[ Source](https://github.com/akiyamaSM/LazyBelongsToMany)[ Packagist](https://packagist.org/packages/inani/lazy-belongs-to-many)[ RSS](/packages/inani-lazy-belongs-to-many/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

LazyBelongsToMany
=================

[](#lazybelongstomany)

A lightweight implementation of Laravel's belongs To many relationship in cases you don't need pivot table.

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

[](#installation)

First, install the package through Composer.

```
composer require inani/lazy-belongs-to-many
```

### Usage

[](#usage)

Suppose we have the following database structure. A `User` can be linked to one or many `Tag`. instead of creating the pivot table we can save tags id list in a column on the user table.

```
| id | name              | tags_id       |
|----|-------------------|---------------|
| 1  | El Houssain inani | [1, 10, 4, 33]|

```

```
