vkoori / laravel-model-dto
There is no license information available for the latest version (0.2.1) of this package.
generate entity dto like dotrine
0.2.1
2025-07-11 19:54 UTC
Requires
- illuminate/console: ^8.0|^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0|^12.0
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
-
Add
\Vkoori\EntityDto\EntityDtoProvider
to Providers list. -
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
- Generate a DTO using Artisan:
php artisan make:dto User --module=Users
- 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.