码迷,mamicode.com
首页 > 其他好文 > 详细

命令创建模型类

时间:2015-08-28 12:31:33      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

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 表已经出现在了数据库里,去看看吧~

命令创建模型类

标签:

原文地址:http://www.cnblogs.com/yuwensong/p/4765965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!