先装上开发插件三件套,开发神器。先不管这能干些啥,装上再说。
1、barryvdh/laravel-debugbar
composer require barryvdh/laravel-debugbar --dev
2、barryvdh/laravel-ide-helper
composer require barryvdh/laravel-ide-helper --dev
3、mpociot/laravel-test-factory-helper
composer require mpociot/laravel-test-factory-helper --dev
然后在config/app.php文件中填上:
- BarryvdhDebugbarServiceProvider::class,
- MpociotLaravelTestFactoryHelperTestFactoryHelperServiceProvider::class,
- BarryvdhLaravelIdeHelperIdeHelperServiceProvider::class,
看下开发插件三件套能干些啥,下文中命令可在项目根目录输入php artisan指令列表中查看。
1、barryvdh/laravel-debugbar
2、barryvdh/laravel-ide-helper
执行php artisan ide-helper:generate指令前:
执行php artisan ide-helper:generate指令后:
不仅Facade模式的Route由之前的反白了变为可以定位到源码了,而且输入Config Facade时还方法自动补全auto complete,这个很方便啊。
输入指令php artisan ide-helper:models后,看看各个Model,如Post这个Model:
- <?php
- namespace App;
- use IlluminateDatabaseEloquentModel;
- /**
- * AppPost
- *
- * @property integer $id
- * @property integer $category_id 外键
- * @property string $title 标题
- * @property string $slug 锚点
- * @property string $summary 概要
- * @property string $content 内容
- * @property string $origin 文章来源
- * @property integer $comment_count 评论次数
- * @property integer $view_count 浏览次数
- * @property integer $favorite_count 点赞次数
- * @property boolean $published 文章是否发布
- * @property CarbonCarbon $created_at
- * @property CarbonCarbon $updated_at
- * @property-read AppCategory $category
- * @property-read IlluminateDatabaseEloquentCollection|AppComment[] $comments
- * @property-read IlluminateDatabaseEloquentCollection|AppTag[] $tags
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereId($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereCategoryId($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereTitle($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereSlug($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereSummary($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereContent($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereOrigin($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereCommentCount($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereViewCount($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereFavoriteCount($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost wherePublished($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereCreatedAt($value)
- * @method static IlluminateDatabaseQueryBuilder|AppPost whereUpdatedAt($value)
- * @mixin Eloquent
- */
- class Post extends Model
- {
- //Post-Category:Many-One
- public function category()
- {
- return $this->belongsTo(Category::class);
- }
- //Post-Comment:One-Many
- public function comments()
- {
- return $this->hasMany(Comment::class);
- }
- //Post-Tag:Many-Many
- public function tags()
- {
- return $this->belongsToMany(Tag::class)->withTimestamps();
- }
- }
根据迁移到库里的表生成字段属性和对应的方法提示,在控制器里输入方法时会自动补全auto complete字段属性的方法:
3、mpociot/laravel-test-factory-helper
输入指令php artisan test-factory-helper:generate后,database/factory/ModelFactory.php模型工厂文件会自动生成各个模型对应字段数据。Faker是一个好用的生成假数据的第三方库,而这个开发插件会自动帮你生成这些属性,不用自己写了
转载:https://blog.csdn.net/h330531987/article/details/79089657
---------------------------------------------------------------------------------------------------------------------------------------
Laravel 日志管理:按日期切割日志
laravel8版本
其他版本