andreykurmel/eloquent_as_doctrine

There is no license information available for the latest version (0.1) of this package.

Hydrate Laravel Entities from Models to use all Eloquent benefits in Service/Repository pattern.

0.1 2022-07-22 14:46 UTC

This package is auto-updated.

Last update: 2025-02-26 19:46:38 UTC


README

Hydrate Laravel Entities from Models to use all Eloquent benefits in Service/Repository pattern.

Laravel Eloquent Model changed to return Entities which can be used as Data Transfer Objects.

Just use "\AndreyKurmel\EloquentAsDoctrine\Models\Model" instead of "\Illuminate\Database\Eloquent\Model".

Class to be used as entity can be set as property:

  • protected $entity = Entity::class;

By default will be used Entity the same as Laravel Model (without database functions). But you can use any other class by implementing interface "\AndreyKurmel\EloquentAsDoctrine\Entities\EloquentInterface"

You can check an example in the folder "src/Example/" (without extra code with interfaces, entry point is "src/Example/Service.php").