PHPackages                             yassinya/laravel-relation-cli - 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. yassinya/laravel-relation-cli

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

yassinya/laravel-relation-cli
=============================

Quickly define relationships between eloquent models with a simple command

v0.2.0(6y ago)7133mitPHPPHP ^7.2

Since Jun 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/yassinya/laravel-relationships-cli)[ Packagist](https://packagist.org/packages/yassinya/laravel-relation-cli)[ RSS](/packages/yassinya-laravel-relation-cli/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (4)Used By (0)

This package allows you to define relationships between your models directly from the command line instead of creating them then setting the relationship methods manually.

Most of the Laravel relationships are supported, including polymorphic ones.

Installation
============

[](#installation)

This package can be installed via composer:

```
composer require yassinya/laravel-relation-cli

```

The service provider will be automatically registered

Publish the config file with:

```
php artisan vendor:publish --provider="Yassinya\Relation\RelationServiceProvider" --tag="config"

```

Usage
=====

[](#usage)

To define a relationship you'll need to use the relation command which expects 3 required arguments:

1. The main model's name
2. The type of the relationship

> **The following abbreviations are used for the relationships**

> - One To One -&gt; 121

> - One to Many -&gt; 12m

> - Many to Many -&gt; m2m

3. Name of the target model

One to One
----------

[](#one-to-one)

```
php artisan relation User 121 Phone

```

> It'll first try to find The models then edit them, and if they don't exist they'll be created

One to Many
-----------

[](#one-to-many)

```
php artisan relation Library 12m Book

```

Many to Many
------------

[](#many-to-many)

```
php artisan relation User m2m Product

```

Polymorphic Relationships
-------------------------

[](#polymorphic-relationships)

To define a polymorphic relationship just add the **-p** or **--polymorphic** option. For instance to define a 121 polymorphic relationship between Post and Image

```
php artisan relation Post 121 Image -p

```

Between User and Image

```
php artisan relation User 121 Image -p

```

###  Health Score

23

—

LowBetter than 25% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.8% 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 ~0 days

Total

3

Last Release

2249d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32034009?v=4)[Yassin Youssouf](/maintainers/yassinya)[@yassinya](https://github.com/yassinya)

---

Top Contributors

[![yassinya](https://avatars.githubusercontent.com/u/32034009?v=4)](https://github.com/yassinya "yassinya (9 commits)")[![yaayes](https://avatars.githubusercontent.com/u/20878658?v=4)](https://github.com/yaayes "yaayes (2 commits)")

---

Tags

eloquentlaravelpackagerelationships

### Embed Badge

![Health badge](/badges/yassinya-laravel-relation-cli/health.svg)

```
[![Health](https://phpackages.com/badges/yassinya-laravel-relation-cli/health.svg)](https://phpackages.com/packages/yassinya-laravel-relation-cli)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M319](/packages/laravel-ai)[spatie/laravel-backup

A Laravel package to backup your application

6.0k25.4M272](/packages/spatie-laravel-backup)[illuminate/queue

The Illuminate Queue package.

20433.0M1.8k](/packages/illuminate-queue)[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React/Svelte) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

5031.3k](/packages/erag-laravel-lang-sync-inertia)[moonshine/moonshine

Laravel administration panel

1.3k268.2k89](/packages/moonshine-moonshine)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

731189.9k16](/packages/tallstackui-tallstackui)

PHPackages © 2026

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