我想把系統做得簡單好用,最好是能節約開發時間。經過考慮,我決定把後端模組化,做成laravel-admin的擴充套件,前端整體做成一個模組。先把核心模組歸納下,後期可能還要加更多模組。
現在通過命令生成所有模組
//修改config/admin.php
'extension_dir' => base_path('modules'),
//執行命令
#基礎和核心
php artisan admin:extend totoro/core --namespace Totoro\Core
#新聞文章
php artisan admin:extend totoro/news --namespace Totoro\News
#企業管理
php artisan admin:extend totoro/enterprise --namespace Totoro\Enterprise
#資訊管理
php artisan admin:extend totoro/community --namespace Totoro\Community
#人才評測
php artisan admin:extend totoro/evaluation --namespace Totoro\Evaluation
//企業服務
php artisan admin:extend totoro/service --namespace Totoro\Service
//會員管理
php artisan admin:extend totoro/member --namespace Totoro\Member
//使用app做為前端模組。就不執行命令了。
執行完成之後,根目錄下多了這些資料夾
把模組新增到專案composer.json
"require": {
//***
"totoro/core": "dev-master",
"totoro/news": "dev-master",
"totoro/community": "dev-master",
"totoro/enterprise": "dev-master",
"totoro/evaluation": "dev-master",
"totoro/service": "dev-master",
"totoro/member": "dev-master"
},
//***
"repositories": [
{
"type": "path",
"url": "modules/totoro/core"
},
{
"type": "path",
"url": "modules/totoro/news"
},
{
"type": "path",
"url": "modules/totoro/community"
},
{
"type": "path",
"url": "modules/totoro/enterprise"
},
{
"type": "path",
"url": "modules/totoro/evaluation"
},
{
"type": "path",
"url": "modules/totoro/service"
},
{
"type": "path",
"url": "modules/totoro/member"
}
]
執行composer update
可以開始做新聞模組了
/**
* 新聞資料表
*/
Schema::create('news', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->unsignedInteger('cate_id')->comment('分類ID');
$table->string('title', 255)->comment('標題');
$table->string('tags')->nullable()->comment('標籤');
$table->string('thumbnail', 255)->nullable()->comment('縮圖');
$table->string('summary', 500)->nullable()->comment('摘要');
$table->text('content')->comment('內容');
$table->text('images')->comment('主圖');
$table->unsignedTinyInteger('status')->comment('狀態:0草稿,1稽核中,2已釋出');
$table->timestamps();
});
/**
* 新聞評論表
*/
Schema::create('news_comments', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('member_id')->comment('會員ID');
$table->unsignedInteger('reply_id')->nullable()->comment('回覆ID');
$table->text('content')->comment('評論內容');
$table->timestamps();
});
/**
* 新聞分類表
*/
Schema::create('news_categories', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->comment('分類');
$table->string('slug');
$table->unsignedInteger('parent_id')->default(0)->comment('上級ID');
$table->unsignedSmallInteger('sort')->default(0)->comment('排序');
$table->string('content', 1000);
});
/**
* 標籤表
*/
Schema::create('news_tags', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->comment('標籤名稱');
$table->string('slug');
});
/**
* 關聯表 關聯新聞
*/
Schema::create('news_relations', function (Blueprint $table) {
$table->unsignedInteger('self_id');
$table->unsignedInteger('target_id');
});
/**
* 關聯表 分類新聞
*/
Schema::create('news_categories_news', function (Blueprint $table) {
$table->unsignedInteger('news_id');
$table->unsignedInteger('cate_id');
});