脚本宝典收集整理的这篇文章主要介绍了Laravel code generator - laragen/laragen,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
GIThub: https://github.com/laragen/la...
命令
php artisan laragen:model User
php artisan laragen:model --all
php artisan laragen:api User
php artisan laragen:api User --model --actions=index,view
php artisan laragen:channel Sms
php artisan laragen:channel Sms --message=mobile,content
php artisan laragen:message Sms
php artisan laragen:message Sms --attributes=mobie,content
生成代码示例
<?php
namespace AppModels;
use IlluminateDatabaseEloquentModel;
use IlluminateDatabaseEloquentRelationsBelongsTo;
use IlluminateDatabaseEloquentRelationsBelongsToMany;
use IlluminateDatabaseEloquentRelationshasmany;
use IlluminateDatabaseEloquentRelationsMorphMany;
use IlluminateDatabaseEloquentRelationsMorphTo;
use IlluminateDatabaseEloquentSoftDeletes;
use IlluminateNotificationsNotifiable;
@H_745_126@class Comment extends Model
{
use SoftDeletes;
public $fillable = ['user_id', 'content', 'commentable_id', 'commentable_type'];
public $casts = [];
public $appends = [];
public $dates = ['deleted_at'];
/**
* Get user
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* Get commentable model
* @return MorphTo
*/
public function commentable(): MorphTo
{
return $this->morphTo();
}
}
以上是脚本宝典为你收集整理的Laravel code generator - laragen/laragen全部内容,希望文章能够帮你解决Laravel code generator - laragen/laragen所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。