命令创建模型类

php artisan make:model Article  
php artisan make:model Page  

 这样,再在app目录下就会有两个文件Article.php 和Page.php.

接下来进行 Article 和 Page 类对应的 articles 表和 pages表的数据库迁移,进入 learnlaravel5/databases/migrations 文件夹。

*createarticles_table.php 中修改:

Schema::create('articles', function(Blueprint $table)  
{
    $table->increments('id');
    $table->string('title');
    $table->string('slug')->nullable();
    $table->text('body')->nullable();
    $table->string('image')->nullable();
    $table->integer('user_id');
    $table->timestamps();
});

*createpages_table.php 中修改:

Schema::create('pages', function(Blueprint $table)  
{
    $table->increments('id');
    $table->string('title');
    $table->string('slug')->nullable();
    $table->text('body')->nullable();
    $table->integer('user_id');
    $table->timestamps();
});

然后执行命令:

php artisan migrate  

成功以后, tables 表和 pages 表已经出现在了数据库里,去看看吧~

posted @ 2015-08-28 11:19  天道酬勤,坚持!  阅读(421)  评论(0编辑  收藏  举报