PHPackages                             desmart/laravel-domain-core - 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. desmart/laravel-domain-core

ActiveLibrary

desmart/laravel-domain-core
===========================

DeSmart core DDD package for Laravel

0.7.1(9y ago)31.1k2MITPHPPHP &gt;=5.6.0

Since Jun 16Pushed 8y ago13 watchersCompare

[ Source](https://github.com/DeSmart/laravel-domain-core)[ Packagist](https://packagist.org/packages/desmart/laravel-domain-core)[ RSS](/packages/desmart-laravel-domain-core/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (8)Versions (14)Used By (0)

Domain core
-----------

[](#domain-core)

### Hydrating models to entities

[](#hydrating-models-to-entities)

Models should use `DeSmart\DomainCore\ConvertsToEntityTrait`. It gives `toEntity()` method which tries to convert the model to entity.

#### Entity class name

[](#entity-class-name)

Entity class name is based on model class name. The convention here is:

```
Module\Model\SomeModel -> Module\Entity\SomeModelEntity

```

Entity class name can be changed. Simply set `$entityClassName` attribute in model definition.

#### Passing data to entity

[](#passing-data-to-entity)

Model is converted to array, and through [`JsonMapper`](https://github.com/netresearch/jsonmapper) all entity properties are set.

#### Passing related models to entity

[](#passing-related-models-to-entity)

`toEntity()` will also map related models to proper entites.
It's done similar to `JsonMapper`.

If needed some relations can be converted through a dedicated method. Simply create `[relationName]ToEntity` method inside your model.

One-to-many relations have to represented as type hinted variadic argument in entity (see example below).

#### Example

[](#example)

```
