定制 vkoori/laravel-model-dto 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vkoori/laravel-model-dto

最新稳定版本:0.2.1

Composer 安装命令:

composer require vkoori/laravel-model-dto

包简介

generate entity dto like dotrine

README 文档

README

Installation

You can install the package via Composer:

composer require vkoori/laravel-model-dto

💡 This package requires Laravel 8+ and PHP 8.0+

Configuration

  1. Add \Vkoori\EntityDto\EntityDtoProvider to Providers list.

  2. Create config/dto.php to define which DTOs should be generated:

return [
    'User' => [
        'id' => [
            'type' => 'int',
            'fillable' => false,
            'cast' => false,
        ],
        'name' => [
            'type' => 'string',
            'fillable' => true,
            'cast' => false,
        ],
        'email' => [
            'type' => '?string',
            'fillable' => true,
            'cast' => false,
        ],
        'status' => [
            'type' => '\App\Enums\StatusEnum',
            'fillable' => true,
            'cast' => true,
        ],
        'is_active' => [
            'type' => 'bool',
            'fillable' => true,
            'cast' => false,
        ],
        'deleted_at' => [
            'type' => '?\Carbon\Carbon',
            'fillable' => false,
            'cast' => false,
        ],
    ],
    // Add more entities as needed
];

Usage

  1. Generate a DTO using Artisan:
php artisan make:dto User --module=Users
  1. Use the Trait in Your Model to automatically setup $fillable and $casts properties
use Illuminate\Database\Eloquent\Model;
use Vkoori\EntityDto\Traits\AutoFillableAndCasts;

class User extends Model
{
    use AutoFillableAndCasts;
}

Support

If you find this package useful, please consider starring it on GitHub or sharing it with others.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-07-11