Skip to content

Commit f4eacf6

Browse files
authored
Merge pull request #742 from opensource-workshop/BbsesPlugin
掲示板の修正(日付の表記の統一)
2 parents cfb6e0e + a88290f commit f4eacf6

File tree

4 files changed

+41
-25
lines changed

4 files changed

+41
-25
lines changed

app/Models/User/Bbses/BbsPost.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,20 @@ public function canEdit()
9494
}
9595
return true;
9696
}
97+
98+
/**
99+
* 更新日時の取得
100+
*/
101+
public function getUpdatedAt($wrong_only = true)
102+
{
103+
// 必ず返却
104+
if ($wrong_only == false) {
105+
return $this->updated_at->format('Y年n月j日 H時i分');
106+
}
107+
108+
// 登録日時と更新日時が違う場合のみ返却
109+
if ($this->updated_at && $this->created_at != $this->updated_at) {
110+
return "(更新:" . $this->updated_at->format('Y年n月j日 H時i分') . "";
111+
}
112+
}
97113
}

resources/views/plugins/user/bbses/default/index.blade.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@
4646
{{-- 一覧での展開方法:すべて閉じるの場合は、card のボディに根記事を含めた記事のタイトル一覧を表示 --}}
4747
<div class="card-body">
4848
{{-- 根記事(スレッドの記事は古い順なので、根記事は最初) --}}
49-
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $post, 'current_post' => null])
49+
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $post, 'current_post' => null, 'list_class' => 'mb-2'])
5050
{{-- スレッド記事 --}}
5151
@foreach ($children_posts->where("thread_root_id", $post->id) as $children_post)
52-
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $children_post, 'current_post' => null])
52+
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $children_post, 'current_post' => null, 'list_class' => 'mb-2'])
5353
@endforeach
5454
</div>
5555
</div>
5656
@else
5757
{{-- 一覧での展開方法:すべて展開 or すべて閉じておく --}}
5858
<div class="card mb-3">
5959
<div class="card-header">
60-
@include('plugins.user.bbses.default.post_title', ['view_post' => $post, 'current_post' => null])
61-
<span class="float-right">{{$post->updated_at->format('Y-m-d')}} [{{$post->created_name}}]</span>
60+
@include('plugins.user.bbses.default.post_title', ['view_post' => $post, 'current_post' => null, 'list_class' => ''])
61+
<span class="float-right">{{$post->created_at->format('Y-m-d')}} [{{$post->created_name}}]</span>
6262
</div>
6363
<div class="card-body">
6464
{!!$post->body!!}
@@ -72,7 +72,7 @@
7272
@endif
7373
<div class="card-body">
7474
@foreach ($children_posts->where("thread_root_id", $post->id) as $children_post)
75-
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $children_post, 'current_post' => null])
75+
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $children_post, 'current_post' => null, 'list_class' => 'mb-2'])
7676
@endforeach
7777
</div>
7878
</div>
@@ -81,8 +81,8 @@
8181
@foreach ($children_posts->where("thread_root_id", $post->id) as $children_post)
8282
<div class="card mt-3">
8383
<div class="card-header">
84-
@include('plugins.user.bbses.default.post_title', ['view_post' => $children_post, 'current_post' => null])
85-
<span class="float-right">{{$children_post->updated_at->format('Y-m-d')}} [{{$children_post->created_name}}]</span>
84+
@include('plugins.user.bbses.default.post_title', ['view_post' => $children_post, 'current_post' => null, 'list_class' => ''])
85+
<span class="float-right">{{$children_post->created_at->format('Y-m-d')}} [{{$children_post->created_name}}]</span>
8686
</div>
8787
<div class="card-body">
8888
{!!$children_post->body!!}

resources/views/plugins/user/bbses/default/post_title_div.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* @category 掲示板プラグイン
77
--}}
88
@if ($plugin_frame->list_underline)
9-
<div class="border-bottom clearfix mb-2">
9+
<div class="border-bottom clearfix {{$list_class}}">
1010
@else
11-
<div class="clearfix mb-2">
11+
<div class="clearfix {{$list_class}}">
1212
@endif
1313
<div class="float-left">
1414
<i class="fas fa-chevron-circle-right"></i>
1515
@include('plugins.user.bbses.default.post_title', ['view_post' => $view_post, 'current_post' => $current_post])
1616
</div>
17-
<div class="float-right">{{$view_post->updated_at->format('Y-m-d')}} [{{$view_post->created_name}}]</div>
17+
<div class="float-right">{{$view_post->created_at->format('Y-m-d')}} [{{$view_post->created_name}}]</div>
1818
</div>

resources/views/plugins/user/bbses/default/show.blade.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,17 @@ function approval_action() {
4747
<h2>{{$post->title}}</h2>
4848

4949
{{-- 投稿日時 --}}
50-
<b>{{$post->created_at->format('Y年n月j日 H時i分')}}</b>
50+
<b>{{$post->created_at->format('Y年n月j日 H時i分')}} [{{$post->created_name}}]</b>
5151
</header>
5252

5353
{{-- 記事本文 --}}
5454
{!! $post->body !!}
5555

5656
{{-- post データは以下のように2重配列で渡す(Laravelが配列の0番目のみ使用するので) --}}
5757
<footer class="row">
58+
<div class="col-12 text-right mb-1">
59+
{{$post->getUpdatedAt()}}
60+
</div>
5861
<div class="col-12 text-right mb-1">
5962
{{-- 一時保存 --}}
6063
@if ($post->status == 1)
@@ -121,15 +124,15 @@ function approval_action() {
121124
<div class="card mb-3">
122125
{{-- 詳細でのスレッド記事の展開方法:すべて閉じるの場合は、card のヘッダに根記事のタイトルを表示 --}}
123126
<div class="card-header">
124-
{{$thread_root_post->title}}@if ($thread_root_post->status == 1) <span class="badge badge-warning align-bottom">一時保存</span>@elseif ($thread_root_post->status == 2) <span class="badge badge-warning align-bottom">承認待ち</span>@endif<span class="float-right">{{$thread_root_post->created_at->format('Y-m-d')}} [{{$thread_root_post->created_name}}]</span>
127+
{{$thread_root_post->title}}@if ($thread_root_post->status == 1) <span class="badge badge-warning align-bottom">一時保存</span>@elseif ($thread_root_post->status == 2) <span class="badge badge-warning align-bottom">承認待ち</span>@endif<span class="float-right">{{$thread_root_post->created_at->format('Y年n月j日')}} [{{$thread_root_post->created_name}}]</span>
125128
</div>
126129
{{-- 詳細でのスレッド記事の展開方法:すべて閉じるの場合は、card のボディに根記事を含めた記事のタイトル一覧を表示 --}}
127130
<div class="card-body">
128131
{{-- 根記事(スレッドの記事は古い順なので、根記事は最初) --}}
129-
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $thread_root_post, 'current_post' => $post])
132+
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $thread_root_post, 'current_post' => $post, 'list_class' => ''])
130133
{{-- スレッド記事 --}}
131134
@foreach ($children_posts->where("thread_root_id", $thread_root_post->id) as $children_post)
132-
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $children_post, 'current_post' => $post])
135+
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $children_post, 'current_post' => $post, 'list_class' => ''])
133136
@endforeach
134137
</div>
135138
</div>
@@ -141,63 +144,60 @@ function approval_action() {
141144
@if ($plugin_frame->thread_format != 0)
142145
{{-- 詳細でのスレッド記事の展開方法が詳細表示している記事のみ展開の場合 --}}
143146
<div class="card-header">
144-
@include('plugins.user.bbses.default.post_title', ['view_post' => $thread_root_post, 'current_post' => $post])
147+
@include('plugins.user.bbses.default.post_title', ['view_post' => $thread_root_post, 'current_post' => $post, 'list_class' => ''])
145148
</div>
146149
{{-- 詳細でのスレッド記事の展開方法:すべて閉じるの場合は、card のボディに根記事を含めた記事のタイトル一覧を表示 --}}
147150
<div class="card-body">
148151
{{-- 根記事(スレッドの記事は古い順なので、根記事は最初) --}}
149152
@if ($thread_root_post->id == $post->id)
150153
<div class="card mb-2">
151154
<div class="card-header">
152-
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $thread_root_post, 'current_post' => $post])
155+
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $thread_root_post, 'current_post' => $post, 'list_class' => ''])
153156
</div>
154157
<div class="card-body">
155158
{!!$thread_root_post->body!!}
156159
</div>
157160
</div>
158161
@else
159-
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $thread_root_post, 'current_post' => $post])
162+
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $thread_root_post, 'current_post' => $post, 'list_class' => ''])
160163
@endif
161164

162165
{{-- スレッド記事 --}}
163166
@foreach ($children_posts->where("thread_root_id", $thread_root_post->id) as $children_post)
164167
@if ($children_post->id == $post->id)
165168
<div class="card mb-2">
166169
<div class="card-header">
167-
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $children_post, 'current_post' => $post])
170+
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $children_post, 'current_post' => $post, 'list_class' => ''])
168171
</div>
169172
<div class="card-body">
170173
{!!$children_post->body!!}
171174
</div>
172175
</div>
173176
@else
174-
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $children_post, 'current_post' => $post])
177+
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $children_post, 'current_post' => $post, 'list_class' => ''])
175178
@endif
176179
@endforeach
177180
</div>
178181
@else
179182
<div class="card-header">
180-
@include('plugins.user.bbses.default.post_title', ['view_post' => $thread_root_post, 'current_post' => $post])
183+
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $thread_root_post, 'current_post' => $post, 'list_class' => ''])
181184
</div>
182185
<div class="card-body">
183186
{!!$thread_root_post->body!!}
184187
@foreach ($children_posts as $children_post)
185188
<div class="card mt-3">
186189
<div class="card-header">
187-
@include('plugins.user.bbses.default.post_title', ['view_post' => $children_post, 'current_post' => $post])
190+
@include('plugins.user.bbses.default.post_title_div', ['view_post' => $children_post, 'current_post' => $post, 'list_class' => ''])
188191
</div>
189192
<div class="card-body">
190193
{!!$children_post->body!!}
191194
</div>
192195
</div>
193196
@endforeach
194-
</div>
197+
</div>
195198
@endif
196199
</div>
197200
@endif
198-
199-
200-
201201
@endif
202202

203203
{{-- / post がある想定の処理 --}}

0 commit comments

Comments
 (0)