From 6359f6a714067a511cb0ad82c3432616945da22b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E4=B8=91=E8=B7=AF=E4=BA=BA?= <2278757482@qq.com> Date: Mon, 18 Jan 2021 13:34:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E6=8B=86=E5=88=86=E5=AD=97=E6=AE=B5=E7=8B=AC=E7=AB=8B=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=90=8C=E6=AD=A5=E6=96=87=E7=AB=A0=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=B5=81=E7=A8=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Entities/Article/Article.php | 6 ++++++ .../Admin/Entities/Article/ArticleContent.php | 11 +++++++++++ .../articles/components/ArticleDetail.vue | 1 - app/Modules/Admin/Services/ArticleService.php | 19 +++++++++++++++++-- 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 app/Modules/Admin/Entities/Article/ArticleContent.php diff --git a/app/Modules/Admin/Entities/Article/Article.php b/app/Modules/Admin/Entities/Article/Article.php index cda0eee..b765207 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 0000000..ac4de3c --- /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; } -- Gitee From 5d2e6648e3547d3d7d2ba0385765892fee4c594e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E4=B8=91=E8=B7=AF=E4=BA=BA?= <2278757482@qq.com> Date: Mon, 18 Jan 2021 18:42:05 +0800 Subject: [PATCH 2/2] update Readme. --- README.en.md | 6 ++++++ README.md | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/README.en.md b/README.en.md index 0bd1b10..297ed31 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 3e76ead..8b2647e 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` -- Gitee