PHPackages                             agpretto/wing - 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. agpretto/wing

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

agpretto/wing
=============

Put the wings to your eloquent models

01PHPCI failing

Since Sep 18Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Mindexperiment/wing)[ Packagist](https://packagist.org/packages/agpretto/wing)[ RSS](/packages/agpretto-wing/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Wing
----

[](#wing)

> This package is a WIP, please don't use until a stable release.

Put the wings to your eloquent models.

This package let you extends your models with a set of json metadata.

### Configuration

[](#configuration)

#### Composer

[](#composer)

Require this package inside your composer.json file

```

"agpretto/wing": "dev-master"

```

Install
-------

[](#install)

This package resolve the problem of adding metadata description to a model. You can assign as many value as you like for a single model to describe everything related to your model instance.

1. Install the package with `wing:install` command.
2. You only need to use the `HasWing` trait on one of your model.

```
namespace App;

use Illuminate\Database\Eloquent\Model;
use Agpretto\Wing\HasWing;

class Article extends Model
{
    use HasWing;
}
```

Usage
-----

[](#usage)

After you install the package you can use the power of Wing for your models. We use an instance of an article model entity to expose the method of this package.

```
// - grab an article

$article = Article::findOrFail(1);
```

### Simple data

[](#simple-data)

Let's assume we want to extends our `Article` instance with a new wing simple data value.

```
// add one simple value

$article->addWing('foo'); // extend the model with a wing

// get the value back

$value = $article->metadata(); // foo
```

### Structured data

[](#structured-data)

Let's now assume we want to extends our `Article` instance with a structured data value.

```
// structured data
$data = [
    'foo' => 'bar',
    'bar' => 'baz',
    'min' => 'max',
];
$article->addWing($data); // extend the model with a wing

// get the values back

$data = $article->metadata(); // stdClass
$data->foo; // bar
$data->bar; // baz
$data->min; // max

// directly access the data

$article->metadata()->foo; // bar
$article->metadata()->bar; // baz
$article->metadata()->min; // max
```

### Complex structured data

[](#complex-structured-data)

Please use the complex structure with caution!

Let's now assume we want to extends our `Article` instance with a complex structure of data.

```
// structured data
$data = [
    'foo' => [ 'foo' => 'bar', 'bar' => 'baz' ],
    'bar' => 'baz',
    'a-strange-key' => [ 'only', 'value' ]
];
$article->addWing($data); // extend the model with a wing

// again, we can get the values back

$data = $article->metadata(); // stdClass
$data->foo; // stdClass
$data->foo->foo; // bar
$data->bar; // baz
$data->{'a-strange-key'}; // stdClass
$data->{'a-strange-key'}[0]; // only

// directly access the data

$article->metadata()->foo; // stdClass
$article->metadata()->foo->foo; // bar
$article->metadata()->bar; // baz
$article->metadata()->{'a-strange-key'}; // stdClass
$article->metadata()->{'a-strange-key'}[0]; // only
```

### Check data

[](#check-data)

You can check if a data exists inside your structured data by using the method `hasMetdata`.

```
// structured data
$data = [
    'foo' => 'bar',
    'bar' => 'baz',
    'min' => 'max',
];
$article->addWing($data); // extend the model with a wing

$article->hasMetadata('foo'); // true
$article->hasMetadata('max'); // false
```

### Update data inside a wing

[](#update-data-inside-a-wing)

Because wing use json data field to store your model structured data inside the database you can use the json notation to update data for the wing relation.

You can find tons of example on how to [work with json data type](https://lmgtfy.com/?q=laravel+json+data+type).

This package provide you 2 simplified methods to update the data of your wing.

#### Update simple structured data

[](#update-simple-structured-data)

Use the `updateData` method to update a simple structure.

```
// structured data
$data = [
    'foo' => 'bar',
    'bar' => 'baz',
    'min' => 'max',
];
$article->addWing($data); // extend the model with a wing

$article->metadata()->foo; // bar

// update wing data
$article->updateWing('foo', 'bong');
$article->refresh(); // reload model relations

$article->metadata()->foo; // bong
```

#### Update part of complex data structure

[](#update-part-of-complex-data-structure)

Use the `updatePartOfWing` to go through your data and update a part of them.

This method simplify the access to the data structure.

```
// structured data
$data = [
    'foo' => [ 'foo' => 'bar', 'bar' => 'baz' ],
    'bar' => 'baz',
    'a-strange-key' => [ 'only', 'value' ]
];
$article->addWing($data); // extend the model with a wing

//update data using a path
$article->updatePartOfWing('foo->foo', 'bong');
$article->refresh(); // reload model relations

$article->metadata()->foo->foo; // bong
```

### Credits

[](#credits)

This package is built for you by the Interstellar Developer [Andrea Giuseppe](https://andreagiuseppe.com) - [Github](https://github.com/Mindexperiment)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae882f2ebee98d1bbcf27d2152e82744ff9d2dec2b628e740b9c2c3879c3b358?d=identicon)[Mindexperiment](/maintainers/Mindexperiment)

---

Top Contributors

[![Mindexperiment](https://avatars.githubusercontent.com/u/42065357?v=4)](https://github.com/Mindexperiment "Mindexperiment (21 commits)")

### Embed Badge

![Health badge](/badges/agpretto-wing/health.svg)

```
[![Health](https://phpackages.com/badges/agpretto-wing/health.svg)](https://phpackages.com/packages/agpretto-wing)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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