andreykurmel / eloquent_as_doctrine
此包的最新版本(0.1)没有可用的许可证信息。
从模型中为Laravel实体注入以在服务/仓库模式中使用所有Eloquent优势。
0.1
2022-07-22 14:46 UTC
Requires
- php: ^8.0
- laravel/framework: ^8.0
README
从模型中为Laravel实体注入以在服务/仓库模式中使用所有Eloquent优势。
将Laravel Eloquent模型更改为返回实体,这些实体可以用作数据传输对象。
只需使用 "\AndreyKurmel\EloquentAsDoctrine\Models\Model" 而不是 "\Illuminate\Database\Eloquent\Model"。
用作实体的类可以作为属性设置
- protected $entity = Entity::class;
默认情况下将使用与Laravel模型相同的实体(不带数据库功能)。但您可以通过实现接口 "\AndreyKurmel\EloquentAsDoctrine\Entities\EloquentInterface" 使用任何其他类。
您可以在 "src/Example/" 文件夹中查看示例(无需额外的接口代码,入口点为 "src/Example/Service.php")。