PHPackages                             danielebarbaro/laravel-entity-details - 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. danielebarbaro/laravel-entity-details

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

danielebarbaro/laravel-entity-details
=====================================

This package provide a list of common fields for a User entity

v1.0.1(4y ago)3352[3 PRs](https://github.com/danielebarbaro/laravel-entity-details/pulls)MITPHPPHP ^8.0|^8.1CI passing

Since Feb 21Pushed 8mo ago2 watchersCompare

[ Source](https://github.com/danielebarbaro/laravel-entity-details)[ Packagist](https://packagist.org/packages/danielebarbaro/laravel-entity-details)[ Docs](https://github.com/danielebarbaro/laravel-entity-details)[ GitHub Sponsors](https://github.com/danielebarbaro)[ RSS](/packages/danielebarbaro-laravel-entity-details/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (1)Dependencies (10)Versions (6)Used By (0)

Entity detail helper
====================

[](#entity-detail-helper)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ef469abf3c3123058c14a772b17eedd8716ca955761e037d738134a460bbe56c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64616e69656c656261726261726f2f6c61726176656c2d656e746974792d64657461696c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danielebarbaro/laravel-entity-details)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4126397ea61d4b32c6f11abce420b74bf305311bd2a7d3dcd5f399a4bf34897c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f64616e69656c656261726261726f2f6c61726176656c2d656e746974792d64657461696c732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/danielebarbaro/laravel-entity-details/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a03d13d2ab75ecdbf071ce9772e0c43f7ad935d17bd672ffb24d492a018f336e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f64616e69656c656261726261726f2f6c61726176656c2d656e746974792d64657461696c732f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/danielebarbaro/laravel-entity-details/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/404209d310a1dc7556eab4e7ad65a662f7b87c1fc823079d7997a4fe8cbd8f6d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64616e69656c656261726261726f2f6c61726176656c2d656e746974792d64657461696c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danielebarbaro/laravel-entity-details)

laravel-entity-details is a package to create and attach some details to a generic Model in a blink of an eye 😎

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

[](#installation)

You can install the package via composer:

```
composer require danielebarbaro/laravel-entity-details
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="entity-details-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="entity-details-config"
```

This is the contents of the published config file:

```
return [
    'table_name' => env('ENTITYDETAIL_TABLE_NAME', 'entity_details'),
    'returns_soft_deleted_models' => env('ENTITYDETAIL_SOFTDETED_ENABLE', false),
];
```

Usage
-----

[](#usage)

Add the traits `EntityDetail` and `EntityDetailHydrate` in your related Model:

```
class User extends Authenticatable
{
    [...]
    use EntityDetail, EntityDetailHydrate;
    [...]
}

[...]

class Biker extends Model
{
    [...]
    use EntityDetail, EntityDetailHydrate;
    [...]
}

[...]

class Company extends Model
{
    [...]
    use EntityDetail, EntityDetailHydrate;
    [...]
}
```

In your `Controller` you can simply save or update detail with the method `syncDetail($detail)`:

```
    [...]
    $user = User::create([
        'name' => 'John',
        'email' => 'Doe',
        'password' => Hash::make('password')
    ]);

    $user->syncDetail([
        'is_company' => true,
        'status' => 1,
        'code' => 'CODE',
        'name' => 'DUMMY COMPANY',
    ]);

    $user->fresh('detail');

    $detail = $user->detail;
    [...]
```

or

```
    [...]
    $company = Company::with('detail')->first();

    $company->syncDetail([
        'is_company' => true,
        'status' => 1,
        'code' => 'CODE',
        'name' => 'DUMMY COMPANY',
    ]);

    $detail = $company->detail;
    [...]
```

Relations
---------

[](#relations)

Traits help you to walk into relations:

```
    $detail = Detail::with('owner')->get();
    $user = $detail->owner;

    [...]

    $biker = Biker::with('detail')->first();
    $detail = $biker->detail;
    [...]
```

Scopes
------

[](#scopes)

Traits help you to use company and owner scope:

```
    $details = Detail::where('status', 1)->isCompany()->get();
    [...]

    $user = User::where('email', 'john@doe.com')->first();
    $detail = Detail::forOwner($user)->first();
    [...]
```

Rules
-----

[](#rules)

Basic rules are:

```
$rules = [
    'is_company' => 'required|boolean',
    'status' => 'required|max:20',
    'code' => 'required|max:10',
    'name' => 'string|max:100',
    'secondary_email' => 'email',
    'sdi' => 'max:7',
    'pec' => 'email',
    'first_name' => 'string|max:60',
    'last_name' => 'string|max:60',
    'phone' => 'string|max:60',
    'mobile' => 'string|max:60',
    'fiscal_code' => 'string|max:16',
    'vat' => 'string|max:13',
    'postal_code' => 'string|max:6',
    'city' => 'string|max:30',
    'country' => 'string|max:2',
    'address' => 'string|max:100',
    'notes' => 'string',
];
```

You can overwrite the `$rules` as you wish in your model, the validator will do the rest

Migration
---------

[](#migration)

Feel free to add or delete fields for Detail entity but remember to edit also the `$rules`.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Daniele Barbaro](https://github.com/danielebarbaro)
- [All Contributors](../../contributors)

Thanks a lot to [Spatie](https://github.com/spatie) ❤️ for making my life easier

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance42

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~23 days

Total

2

Last Release

1518d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7653cedfb706bdbaceab17cb57fa55d5e2744faeb722cfc1e2af8c3fd88f13ef?d=identicon)[danielebarbaro](/maintainers/danielebarbaro)

---

Top Contributors

[![danielebarbaro](https://avatars.githubusercontent.com/u/4376886?v=4)](https://github.com/danielebarbaro "danielebarbaro (24 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (11 commits)")[![massimomarazzi](https://avatars.githubusercontent.com/u/1248197?v=4)](https://github.com/massimomarazzi "massimomarazzi (2 commits)")

---

Tags

laravelmodelphprelationslaraveldanielebarbarolaravel-entity-details

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/danielebarbaro-laravel-entity-details/health.svg)

```
[![Health](https://phpackages.com/badges/danielebarbaro-laravel-entity-details/health.svg)](https://phpackages.com/packages/danielebarbaro-laravel-entity-details)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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