0
点赞
收藏
分享

微信扫一扫

laravel关于artisan命令能实现的功能

ZGtheGreat 2022-06-06 阅读 86

创建控制器

  1. ​php artisan make:controller StudentController​

创建Rest风格资源控制器(带有index、create、store、edit、update、destroy、show方法)

  1. ​php artisan make:controller PhotoController --resource​

创建模型

  1. ​php artisan make:model Student​
  2. php artisan make:model User –migration 创建模型并创建新迁移

创建新建表的迁移和修改表的迁移

  1. ​php artisan make:migration create_users_table --create=students //创建students表​
  2. ​php artisan make:migration add_votes_to_users_table --table=students//给students表增加votes字段​

执行迁移

  1. ​php artisan migrate​
  2. php artisan migrate:rollback   回滚最新一次迁移

创建模型的时候同时生成新建表的迁移

  1. ​php artisan make:model Student -m​

回滚上一次的迁移

  1. ​php artisan migrate:rollback​

回滚所有迁移

  1. ​php artisan migrate:reset​
  2. php artisan migrate:refresh  更新表结构

创建填充

  1. ​php artisan make:seeder StudentTableSeeder​

执行单个填充

  1. ​php artisan db:seed --class=StudentTableSeeder​

执行所有填充

  1. ​php artisan db:seed​

创建中间件(app/Http/Middleware 下)

  1. ​php artisan make:middleware Activity​

创建队列(数据库)的表迁移(需要执行迁移才生效)

  1. ​php artisan queue:table​

创建队列类(app/jobs下):

  1. ​php artisan make:job SendEmail​

创建请求类(app/Http/Requests下)

  1. ​php artisan make:request CreateArticleRequest​
举报

相关推荐

0 条评论