Skip to content

Commit

Permalink
complete transform logic
Browse files Browse the repository at this point in the history
  • Loading branch information
summerblue committed Apr 7, 2017
1 parent e06fdc6 commit 882ddfd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions app/Http/Controllers/ArticlesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public function transform($id)
$topic->update([
'category_id' => config('phphub.blog_category_id')
]);

// attach blog
$blog = Auth::user()->blogs()->first();
$blog->topics()->attach($topic->id);
$blog->increment('article_count', 1);
// Co-authors
if ( ! $blog->authors()->where('user_id', $topic->user_id)->exists()) {
$blog->authors()->attach($topic->user_id);
}

Flash::success(lang('Operation succeeded.'));
return redirect()->to($topic->link());
}
Expand Down
9 changes: 6 additions & 3 deletions resources/views/topics/partials/topic_operate.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@
<a id="topic-append-button" href="javascript:void(0);" class="admin popover-with-html" data-toggle="modal" data-target="#exampleModal" data-content="帖子附言,添加附言后所有参与讨论的用户都能收到消息提醒,包括点赞和评论的用户">
<i class="fa fa-plus"></i>
</a>
<a data-method="patch" data-btn="transform-button" href="javascript:void(0);" data-url="{{ route('articles.transform', [$topic->id]) }}" class="admin popover-with-html" data-content="转换话题为专栏文章">
<i class="fa fa-rocket" aria-hidden="true"></i>
</a>

@if ($topic->user->blogs()->count() > 0)
<a data-method="patch" data-btn="transform-button" href="javascript:void(0);" data-url="{{ route('articles.transform', [$topic->id]) }}" class="admin popover-with-html" data-content="转换话题为专栏文章">
<i class="fa fa-rocket" aria-hidden="true"></i>
</a>
@endif
@endif

</div>
Expand Down

0 comments on commit 882ddfd

Please sign in to comment.