diff --git a/README.en.md b/README.en.md index 0bd1b1004be4fd79f3434d0d591b3f3c407d0478..297ed319dd33830f5f62346b16d0104edb77fccf 100644 --- a/README.en.md +++ b/README.en.md @@ -17,6 +17,12 @@ Software architecture description #### Installation +###### 安装Vue +* 安装 npm 包:`npm install` +* 热更新vue项目:`npm run watch-poll` +* 执行vue项目:`npm run dev` + +###### PHP设置 * 命令行:`composer install` * 命令行:`cp .env.example .env` * 命令行,生成 APP_KEY:`php artisan key:generate` diff --git a/README.md b/README.md index 3e76eada75bffd25103bd2781dd8c246ada3635c..8b2647e271a79193a6429daee71f9466ff306601 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,12 @@ #### 安装教程 +###### 安装Vue +* 安装 npm 包:`npm install` +* 热更新vue项目:`npm run watch-poll` +* 执行vue项目:`npm run dev` + +###### PHP设置 * 命令行:`composer install` * 命令行:`cp .env.example .env` * 命令行,生成 APP_KEY:`php artisan key:generate` diff --git a/app/Modules/Admin/Entities/Article/Article.php b/app/Modules/Admin/Entities/Article/Article.php index cda0eeea82bc5fd240c9c2eda6991dcd52373ad3..b7652078d4376f81130c67e966d87ec908046c28 100644 --- a/app/Modules/Admin/Entities/Article/Article.php +++ b/app/Modules/Admin/Entities/Article/Article.php @@ -28,6 +28,12 @@ class Article extends Model return $this->hasOne(ArticleCategory::class, 'category_id', 'category_id'); } + public function content() + { + $primaryKey = $this->getKeyName(); + return $this->hasOne(ArticleContent::class, $primaryKey, $primaryKey); + } + public function labels() { return $this->belongsToMany(ArticleLabel::class, ArticleWithLabel::class, 'article_id' , 'label_id' , 'article_id', 'label_id')->withPivot(['article_id', 'label_id']); diff --git a/app/Modules/Admin/Entities/Article/ArticleContent.php b/app/Modules/Admin/Entities/Article/ArticleContent.php new file mode 100644 index 0000000000000000000000000000000000000000..ac4de3c4cfab5bb2080164a844193d15cd06fb8a --- /dev/null +++ b/app/Modules/Admin/Entities/Article/ArticleContent.php @@ -0,0 +1,11 @@ +detail->content()->create([ + 'article_id' => $this->detail->article_id, + 'article_content' => $params['article_content'] ?? '', + 'created_ip' => $ip_agent['ip'] ?? get_ip(), + 'browser_type' => $ip_agent['agent'] ?? $_SERVER['HTTP_USER_AGENT'], + ]); + + // 设置文章标签 $this->setArticleLabels($params); DB::commit(); return true; - }catch (Exception $exception){ + }catch (Exception $e){ + var_dump($e->getMessage()); DB::rollBack(); return false; } @@ -75,11 +86,15 @@ class ArticleService extends BaseService try{ parent::update($params); // TODO: Change the autogenerated stub + // 更新文章内容 + $this->detail->content()->where('article_id', $this->detail->article_id)->update(['article_content' => $params['article_content'] ?? '']); + + // 设置文章标签 $this->setArticleLabels($params); DB::commit(); return true; - }catch (Exception $exception){ + }catch (Exception $e){ DB::rollBack(); return false; }