PHPackages                             testinstance/laravel-model-profiles - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. testinstance/laravel-model-profiles

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

testinstance/laravel-model-profiles
===================================

Laravel Model Profiles - Vertical Based Model Data Expansion On Key Value

1.0(4y ago)110[1 issues](https://github.com/Test-Instance/Laravel-Model-Profiles/issues)MITPHPPHP ^8.0

Since Dec 24Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Test-Instance/Laravel-Model-Profiles)[ Packagist](https://packagist.org/packages/testinstance/laravel-model-profiles)[ RSS](/packages/testinstance-laravel-model-profiles/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

[![](https://raw.githubusercontent.com/Test-Instance/Laravel-Model-Profiles/master/.github/images/testinstancebanner.png)](https://testinstance.co.uk)

[![Total Downloads](https://camo.githubusercontent.com/5cc660574c09e11db3588111321cfef2860f24d284962180a512f5df25a84f98/68747470733a2f2f706f7365722e707567782e6f72672f74657374696e7374616e63652f6c61726176656c2d6d6f64656c2d70726f66696c65732f642f746f74616c2e737667)](https://packagist.org/packages/testinstance/laravel-model-profiles)[![Latest Version](https://camo.githubusercontent.com/039ede9837c66c05a6fbd730850d0bb892eb174ec64dbee8c66531b9116aedcf/68747470733a2f2f706f7365722e707567782e6f72672f74657374696e7374616e63652f6c61726176656c2d6d6f64656c2d70726f66696c65732f76657273696f6e2e737667)](https://packagist.org/packages/testinstance/laravel-model-profiles)[![License](https://camo.githubusercontent.com/97a587813b93fa6a20df4be7cbbf422a26a011168d34b977b8ad5d960fa1f4cb/68747470733a2f2f706f7365722e707567782e6f72672f74657374696e7374616e63652f6c61726176656c2d6d6f64656c2d70726f66696c65732f6c6963656e73652e737667)](https://packagist.org/packages/testinstance/laravel-model-profiles)

Laravel Model Profiles
----------------------

[](#laravel-model-profiles)

Laravel Model Profiles allows the extension of conventional normalization forms where scaling is seen to be completed via rows representing value with data types and relational keys rather than additional tables and key based relations.

Note - ONLY COMPATIBLE WITH [LARAVEL FRAMEWORK](https://packagist.org/packages/laravel/framework)

#### Why?

[](#why)

Profile tables allow the expansion or reduction of data points against a model without the need to add new columns to the original model table. For example, a 400 column table of data could be compressed down to a 1 column (primaryKey id) table.

---

Setup
-----

[](#setup)

- (version 1) Your models must live within `App/Models`
- (version 2 onward) \[WIP\] Set your model path and migration path within the `app/config/profiles.php` file. These tell Laravel Model Profiles where to inject new profile models &amp; migrations via creation. Default is `App/Models` &amp; `database/migrations`

---

Usage
-----

[](#usage)

### Installation

[](#installation)

`composer require testinstance/laravel-model-profiles`

---

> We will use 'User.php' model as an example for this usage guide.

### Make Model Profile

[](#make-model-profile)

In order to use Laravel Model Profiles you must use the 'use HasProfile' trait on your selected model class. 'use TestInstance\\LaravelModelProfiles\\Traits\\HasProfile;'.

Run `php artisan make:profile ModelScope\ModelClassName`

- example: `php artisan make:profile User\User`. This will create a profile for the User.php Model.

You will see that two new models and a migration file are created:

- `App/Models/User/UserProfile.php`
- `App/Models/User/UserProfileKey.php`
- `database/migrations/{timestamp}_user_profile.php`

Run `php artisan migrate`

You will see that the `user_profiles` table is created with:

- id
- user\_id
- user\_profile\_key\_id
- value
- created\_at
- updated\_at
- deleted\_at
- deleted\_at\_unique

You will see that the `user_profile_keys` table is created with:

- id
- name
- type
- created\_at
- updated\_at

### Interactions

[](#interactions)

#### Retrieve by profile value

[](#retrieve-by-profile-value)

```
//'color' is the name of the profileKey related to the model - 'user_profile_keys.name'
//'blue' is the value of the profile related to the model - 'user_profiles.value'
$users = User::whereProfile('color', 'blue')->get();

```

`$users` will be a collection of `users` which have the profile value of `blue` for the `profile_key` name of `color`

`whereProfile` &amp; `whereProfileIn` are a direct pass-through to the native Laravel `where` &amp; `whereIn` so can be used as such. (Including searching for multiple parameters as an array: `whereProfile(['color' => 'blue', 'anotherProfileKey' => 'anotherProfileValue'])`).

The profileKey type will dictate which data type it relates to and will be casted as such. The available types are listed in the Laravel documentation [here](https://laravel.com/docs/8.x/eloquent-mutators#attribute-casting). Model casting in profile is an extension and will be documented after its full release.

#### Save profile value

[](#save-profile-value)

To save a profile value you can simple use the following format:

```
$user->color = 'blue';
$user->save();

```

### Eagerloading

[](#eagerloading)

Every model with a profile will eagerload its profile. Profile attributes can be accessed the same way model attributes are.

- example: `$user->color` will return `blue` even if the attribute 'color' does not exist as a column on user.

### Notes

[](#notes)

- Mass Assignment

> Updating a model with profile attributes loaded will not be affected by profile.

- Model Casting

> Casting model profile type to another model is \[WIP\]

- Unit Tests

> Unit tests exist for profile, however model specific tests do not. These are \[WIP\]. These can be created manually in the current version

---

Dependencies
------------

[](#dependencies)

- Laravel Framework: "^8.75" (Recommended)
- PHP: "^8.0"

---

Security
--------

[](#security)

Please notify us of any security issues or concerns via

---

License
-------

[](#license)

Laravel Model Profiles is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

Authors
-------

[](#authors)

[Ballard-dev](https://github.com/Ballard-dev)[KieranFYI](https://github.com/KieranFYi)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

1597d ago

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/f832931278f6388dde92ac51438572e9d8c44e4c99a7a72f1916a1779d3f90c2?d=identicon)[Ballard-dev](/maintainers/Ballard-dev)

---

Top Contributors

[![Ballard-dev](https://avatars.githubusercontent.com/u/74719533?v=4)](https://github.com/Ballard-dev "Ballard-dev (50 commits)")

### Embed Badge

![Health badge](/badges/testinstance-laravel-model-profiles/health.svg)

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

PHPackages © 2026

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