diff --git a/app/Http/Controllers/Home/Comment.php b/app/Http/Controllers/Home/Comment.php index 08698eb..c755629 100644 --- a/app/Http/Controllers/Home/Comment.php +++ b/app/Http/Controllers/Home/Comment.php @@ -20,8 +20,8 @@ class Comment { 'user_id' => ($r->user_id != 0 ?: null), 'post_id' => ($r->isvideo == 'f' ? $id : 0), 'video_id' => ($r->isvideo == 't' ? $r->slug : ''), - 'name' => $com['name'], - 'email' => $com['mail'], + 'name' => (isset($com['name']) ? $com['name'] : null), + 'email' => (isset($com['mail']) ? $com['mail'] : null), 'message' => $com['text'], 'created' => time(), 'ipaddress' => getIp(), @@ -33,12 +33,14 @@ class Comment { $res = DB::table('blg_comments')->select('id', 'name', 'created', 'message')->where('id', $add)->first(); $res->created = date('Y年m月d日 H:i:s', $res->created); - if (count(userDetail($r->user_id)) > 0) { + if (!is_null($r->user_id) && !empty(userDetail($r->user_id))) { $det = userDetail($r->user_id); $res->user_id = $det['user_id']; $res->showname = $det['showname']; $res->showcol = $det['showcol']; $res->avatar = $det['avatar']; + $res->replyCount = 0; + $res->isvideo = $r->isvideo; } return array('status' => '010100', 'message' => 'OK', 'result' => $res); diff --git a/app/Http/Controllers/Home/CommentList.php b/app/Http/Controllers/Home/CommentList.php index aacc1cc..81a155c 100644 --- a/app/Http/Controllers/Home/CommentList.php +++ b/app/Http/Controllers/Home/CommentList.php @@ -38,7 +38,7 @@ class CommentList { $g->name_style = $p->name_style; $g->display_name = $p->display_name; - if (count(userDetail($g->user_id)) > 0) { + if (!empty(userDetail($g->user_id))) { $det = userDetail($g->user_id); $g->user_id = $det['user_id']; $g->showname = $det['showname']; diff --git a/app/Http/Controllers/Home/Index.php b/app/Http/Controllers/Home/Index.php index 1831096..a5cfbb2 100644 --- a/app/Http/Controllers/Home/Index.php +++ b/app/Http/Controllers/Home/Index.php @@ -62,7 +62,10 @@ class Index { $get->display_name = $p->display_name; foreach ($get->comments['come'] as $k => $c) { - if (count(userDetail($c->user_id)) > 0) { + $c->replyCount = 0; + $c->isvideo = 'f'; + + if (!is_null($c->user_id) && !empty(userDetail($c->user_id))) { $det = userDetail($c->user_id); $c->user_id = $det['user_id']; $c->showname = $det['showname']; diff --git a/app/Http/Controllers/User/MemberList.php b/app/Http/Controllers/User/MemberList.php index a246925..9597b9d 100644 --- a/app/Http/Controllers/User/MemberList.php +++ b/app/Http/Controllers/User/MemberList.php @@ -42,7 +42,7 @@ class MemberList { $d = DB::table('usr_details')->select('reg_date')->where('user_id', $g->id)->first(); $g->reg_date = date('Y年m月d日 H:i:s', $d->reg_date); - if (count(userDetail($g->id)) > 0) { + if (!empty(userDetail($g->id))) { $det = userDetail($g->id); $g->showname = $det['showname']; $g->showcol = $det['showcol']; diff --git a/app/Http/Controllers/Video/Prayer.php b/app/Http/Controllers/Video/Prayer.php index 72c900f..2d17897 100644 --- a/app/Http/Controllers/Video/Prayer.php +++ b/app/Http/Controllers/Video/Prayer.php @@ -46,7 +46,10 @@ class Prayer { $res->lbcomment = array(); foreach ($comments as $k => $c) { - if (count(userDetail($c->user_id)) > 0) { + $c->replyCount = 0; + $c->isvideo = 't'; + + if (!is_null($c->user_id) && !empty(userDetail($c->user_id))) { $det = userDetail($c->user_id); $c->user_id = $det['user_id']; $c->showname = $det['showname']; @@ -68,6 +71,8 @@ class Prayer { $res->user = userDetail(null, $this->cook); $res->comments['total'] = count($comments); $res->comments['come'] = $comments; + $res->comments['total'] += $res->ytcomment['total']; + $res->comments['come'] = array_merge($res->comments['come'], $res->ytcomment['come']); return view('pages.site.video.prayer', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]); } @@ -106,6 +111,7 @@ class Prayer { $g->comment->created = date('Y年m月d日 H:i:s', strtotime($g->snippet->topLevelComment->snippet->publishedAt)); $g->comment->message = strip_tags($g->snippet->topLevelComment->snippet->textDisplay, array('
')); $g->comment->replyCount = (isset($g->snippet->totalReplyCount) ? $g->snippet->totalReplyCount : 0); + $g->comment->isvideo = 'n'; if (isset($g->replies)) { $g->comment->replies = array(); diff --git a/app/helpers.php b/app/helpers.php index b8a6456..ac0002c 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -60,7 +60,7 @@ function userDetail ($id, $kero=null) { return array('user_id' => $user_id, 'showname' => $showname, 'showcol' => $showcol, 'avatar' => $p3->avatar); } - return array(); + return new \stdClass(); } ?> diff --git a/public/img/Eqjk_WgVQAE2psn.jpeg b/public/img/Eqjk_WgVQAE2psn.jpeg new file mode 100644 index 0000000..86bd4c4 Binary files /dev/null and b/public/img/Eqjk_WgVQAE2psn.jpeg differ diff --git a/resources/js/components/comments.vue b/resources/js/components/comments.vue index 4b04d05..05d6985 100644 --- a/resources/js/components/comments.vue +++ b/resources/js/components/comments.vue @@ -1,15 +1,54 @@ @@ -93,11 +95,6 @@ export default { props: { user: Object, slug: '', isvideo: '', comments: Object }, data: function () { return { comment: this.comments, newComment: {}, err: '', loading: true, sending: false } }, - computed: { - total: function () { - return this.comment.length; - } - }, created: function () { this.reset(); }, methods: { reset () { @@ -107,24 +104,22 @@ this.newComment.text = ''; }, send () { - if (this.isvideo !== 'n') { - this.err = ''; - this.sending = true; + this.err = ''; + this.sending = true; - axios.post('/api/comment/new', { - user_id: this.user.user_id, - comment: this.newComment, - isvideo: this.isvideo, - slug: this.slug - }).then(res => { - this.sending = false; - if (res.data.status === '010100') { this.comment.push(res.data.result); this.reset(); } - else this.err = 'エラーコード【' + res.data.status + '】' + res.data.message; - }).catch(err => { - this.sending = false; - this.err = 'サーバーエラーコード【' + err.response.status + '】' + err.response.data.message; - }); - } + axios.post('/api/comment/new', { + user_id: this.user.user_id, + comment: this.newComment, + isvideo: this.isvideo, + slug: this.slug + }).then(res => { + this.sending = false; + if (res.data.status === '010100') { this.comment.come.unshift(res.data.result); this.comment.total++; this.reset(); } + else this.err = 'エラーコード【' + res.data.status + '】' + res.data.message; + }).catch(err => { + this.sending = false; + this.err = 'サーバーエラーコード【' + err.response.status + '】' + err.response.data.message; + }); } } } diff --git a/resources/views/pages/site/video/prayer.blade.php b/resources/views/pages/site/video/prayer.blade.php index 233eaac..6d15754 100644 --- a/resources/views/pages/site/video/prayer.blade.php +++ b/resources/views/pages/site/video/prayer.blade.php @@ -31,56 +31,8 @@ @endif
- - -
-
- -
- @if ($res->ytcomment) -
- -
- @endif - @if ($res->nicocomment) -
- -
- @endif - @if ($res->bccomment) -
- -
- @endif - @if ($res->lbcomment) -
- -
- @endif +
+