Laravel code generator - laragen/laragen

发布时间:2019-08-08 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了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,请注明来意。