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 表已经出现在了数据库里,去看看吧~
版权声明
本文仅代表作者观点,不代表百度立场。
本文系作者授权百度百家发表,未经许可,不得转载。





