niefufeng/laravel-model-typescript

该包最新版本(0.1.0)没有提供许可证信息。

将 Laravel 模型转换为 TypeScript 接口

0.1.0 2023-09-04 21:11 UTC

This package is auto-updated.

Last update: 2024-09-04 23:11:06 UTC


README

  • php >= 8.1
  • 如果使用注释给 getter 设置返回值,返回 Illuminate\\Database\\Eloquent\\Casts\\Attribute 类,不能简写为 Attribute
  • 如果使用 Illuminate\\Database\\Eloquent\\Casts\\Attribute 作为返回值,需要给 get 也写上返回值,比如 Attribute::get(fn(): string => 'hello'),否则将会生成 any

使用方法

# install
composer require niefufeng/laravel-model-typescript --dev
# publish config files
php artisan vendor:publish --tag=model-typescript
# generate
php artisan model-typescript:generate