laravel部分命令

来源:互联网 发布:熊掌好吃吗 知乎 编辑:程序博客网 时间:2024/06/06 13:11
//中间件
php artisan make:middleware classname
//拉取下来
php artisan key:generate


//创建控制器
php artisan make:controller BlogController
//创建model & 迁移文件
php artisan make:model test -m
//创建迁移文件
php artisan make:migration create_posts_table
//生成数据库文件
php artisan migrate
php artisan migrate:reset
//填充数据
//创建填充数据类文件
php artisan make:seeder products


$arr =[];
for(){
$tmp = [];
$tmp['typeid'] = rand(1,10);
$tmp['goods'] = str_random(20);
$arr[] = $tmp;
}
DB::table('products')->insert($arr);


//生成测试数据
php artisan db:seed --class=products




$table->bigIncrements('id'); 递增 ID(主键),相当于「UNSIGNED BIG INTEGER」型态。
$table->bigInteger('votes'); 相当于 BIGINT 型态。
$table->binary('data'); 相当于 BLOB 型态。
$table->boolean('confirmed'); 相当于 BOOLEAN 型态。
$table->char('name', 4); 相当于 CHAR 型态,并带有长度。
$table->date('created_at'); 相当于 DATE 型态。
$table->dateTime('created_at'); 相当于 DATETIME 型态。
$table->dateTimeTz('created_at'); DATETIME (with timezone) 带时区形态
$table->decimal('amount', 5, 2); 相当于 DECIMAL 型态,并带有精度与基数。
$table->double('column', 15, 8); 相当于 DOUBLE 型态,总共有 15 位数,在小数点后面有 8 位数。
$table->enum('choices', ['foo', 'bar']); 相当于 ENUM 型态。
$table->float('amount'); 相当于 FLOAT 型态。
$table->increments('id'); 递增的 ID (主键),使用相当于「UNSIGNED INTEGER」的型态。
$table->integer('votes'); 相当于 INTEGER 型态。
$table->ipAddress('visitor'); 相当于 IP 地址形态。
$table->json('options'); 相当于 JSON 型态。
$table->jsonb('options'); 相当于 JSONB 型态。
$table->longText('description'); 相当于 LONGTEXT 型态。
$table->macAddress('device'); 相当于 MAC 地址形态。
$table->mediumInteger('numbers'); 相当于 MEDIUMINT 型态。
$table->mediumText('description'); 相当于 MEDIUMTEXT 型态。
$table->morphs('taggable'); 加入整数 taggable_id 与字符串 taggable_type。
$table->nullableTimestamps(); 与 timestamps() 相同,但允许为 NULL。
$table->rememberToken(); 加入 remember_token 并使用 VARCHAR(100) NULL。
$table->smallInteger('votes'); 相当于 SMALLINT 型态。
$table->softDeletes(); 加入 deleted_at 字段用于软删除操作。
$table->string('email'); 相当于 VARCHAR 型态。
$table->string('name', 100); 相当于 VARCHAR 型态,并带有长度。
$table->text('description'); 相当于 TEXT 型态。
$table->time('sunrise'); 相当于 TIME 型态。
$table->timeTz('sunrise'); 相当于 TIME (with timezone) 带时区形态。
$table->tinyInteger('numbers'); 相当于 TINYINT 型态。
$table->timestamp('added_on'); 相当于 TIMESTAMP 型态。
$table->timestampTz('added_on'); 相当于 TIMESTAMP (with timezone) 带时区形态。
$table->timestamps(); 加入 created_at 和 updated_at 字段。
$table->uuid('id'); 相当于 UUID 型态。