环境搭建
composer create-project laravel/laravel=5.5 blogvue --prefer-dist
// 安装 npm 依赖包
npm install
"devDependencies": {
"axios": "^0.16.2",
"bootstrap-sass": "^3.3.7",
"chart.js": "^2.4.0",
"ionicons": "^2.0.1",
"cross-env": "^5.0.1",
"jquery": "^3.1.1",
"laravel-mix": "^1.0",
"lodash": "^4.17.4",
"vue": "^2.1.10",
"vue-datepicker": "^1.3.0",
"vue-i18n": "^6.0.0",
"vue-multiselect": "^2.0.0",
"vue-router": "^2.1.1",
"vuex": "^2.1.1",
"cropperjs": "^1.0.0",
"emojione": "^2.2.7",
"fine-uploader": "^5.14.2",
"v-textcomplete": "^0.1.2",
"sweetalert": "^1.1.3",
"toastr": "^2.1.2",
"path-to-regexp": "^1.7.0"
}
一些需要注意的事项
.env 文件
php artisan key:generate生成迁移
php artisan make:migration create_articles_table
php artisan make:migration create_tags_table
php artisan make:migration create_visitors_table
php artisan make:migration create_categories_table
php artisan make:migration create_discussions_table
php artisan make:migration create_comments_table
php artisan make:migration create_links_table
php artisan make:migration create_taggables_table
php artisan make:migration create_followers_table
php artisan make:migration create_notifications_table
php artisan make:migration create_failed_jobs_table
php artisan make:migration create_votes_table
- 填充迁移文件
/app/Providers/AppServiceProvider.class.php
use Illuminate\Support\Facades\Schema;
boot() {
Schema::defaultStringLength(191);
}
- 生成模型文件
php artisan make:model Article
php artisan make:model Category
php artisan make:model Comment
php artisan make:model Discussion
php artisan make:model Follower
php artisan make:model Helpers
php artisan make:model Link
php artisan make:model Tag
php artisan make:model Visitor
- 安装 composer 依赖
修改 composer.json 文件
"minimum-stability": "dev", // 最低稳定性要求的 dev 版本
"prefer-stable": true
composer require jcc/laravel-vote -vvv
You made a reference to a non-existent script @php artisan package:discover
需要将 composer 升级到最新版本
composer self-update
- 生成填充文件
php artisan make:seeder ArticlesTableSeeder
php artisan make:seeder CategoriesTableSeeder
php artisan make:seeder CommentsTableSeeder
php artisan make:seeder DiscussionsTableSeeder
php artisan make:seeder LinksTableSeeder
php artisan make:seeder TagsTableSeeder
php artisan make:seeder VisitorsTableSeeder
php artisan make:seeder UsersTableSeeder
填写数据工厂文件 UserFactory.php
补充 Transformers 文件夹
DiscussionTransformer
public function includeComments(Discussion $discussion)
includeComments 是怎么实现的哩,怎么调用
morphMany
morphToMany
morphedByMany
这两个字段是么意思
commentable_id
commentable_type