Eloquent是Laravel内置的ORM系统
php artisan make:model 名字;//在app目录下创建继承自Eloquent的Model的模型
不用写东西功能就已经很强大了
数据迁移,创建Migration
php artisan make:migration 模型名
在database下的migrations目录下,有个up方法
function up(){
Schema::create('articles',function(Blueprint $table){
$table->increment('id');
$table->string('title');
//还有text,integer,timestamps方法
});
}生成Seeder,播种机,填充测试数据等
php artisan make:seeder 模型名Seeder
生成在database/seeds 目录下
public function run(){
DB::table('artical')->create();//循环插入数据
}随后在database/seeds/DatabaseSeeder.php里面的run()写
public function run(){
$this->call(ArticleSeeder::class);
}php artisan db:seed