質問編集履歴

2

誤字を修正しました。

2021/03/13 11:38

投稿

ohshiro_hide
ohshiro_hide

スコア3

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- (例)PHP(laravel5.8)でブログのシステムを作っています。
7
+ PHP(laravel5.8)でブログのシステムを作っています。
8
8
 
9
9
  削除機能を実装中に以下のエラーメッセージが発生しました。
10
10
 

1

list.blade.phpコードを追加しました。

2021/03/13 11:38

投稿

ohshiro_hide
ohshiro_hide

スコア3

test CHANGED
File without changes
test CHANGED
@@ -238,7 +238,119 @@
238
238
 
239
239
  ```
240
240
 
241
-
241
+ ```
242
+
243
+ list.blade.php(ブログ一覧画面)
244
+
245
+
246
+
247
+ @extends('../layouts/app')
248
+
249
+ @section('title', 'ブログ')
250
+
251
+ @auth
252
+
253
+ @php
254
+
255
+ $title = __('You\'ve verified your email address.');
256
+
257
+ @endphp
258
+
259
+ @section('content')
260
+
261
+ <div class="row">
262
+
263
+ <div class="col-md-10 col-md-offset-2">
264
+
265
+ <h2>ブログ記事一覧</h2>
266
+
267
+ <button type="button" class="btn btn-primary" onclick="location. href='/blog/create'">新規登録</button>
268
+
269
+ @if(session('err_msg'))
270
+
271
+ <p class="text-danger">{{session('err_msg')}}</p>
272
+
273
+ @endif
274
+
275
+
276
+
277
+ <table class="table table-striped">
278
+
279
+ <tr>
280
+
281
+ <th>記事番号</th>
282
+
283
+ <th>タイトル</th>
284
+
285
+ <th>日付</th>
286
+
287
+ <th></th>
288
+
289
+ <th></th>
290
+
291
+ </tr>
292
+
293
+ @foreach($blogs as $blog)
294
+
295
+ <tr>
296
+
297
+ <td>{{ $blog->id }}</td>
298
+
299
+ <td><a href="/blog/{{ $blog->id }}">{{ $blog->title }}</a></td>
300
+
301
+ <td>{{ $blog->updated_at }}</td>
302
+
303
+ <td><button type="button" class="btn btn-primary" onclick="location. href='/blog/edit/{{ $blog->id }}'">編集</button></td>
304
+
305
+ <td><button type="button" class="btn btn-primary" onclick="location. href='/blog/checkdelete/{{ $blog->id }}'">削除</button></td>
306
+
307
+ <!-- <form method="post" action="{{ route('delete',$blog->id) }}" onSubmit="return checkDelete()">
308
+
309
+  @csrf
310
+
311
+ <td><button type="submit" class="btn btn-primary" onclick=>削除</button></td>
312
+
313
+ </form> -->
314
+
315
+ </tr>
316
+
317
+ @endforeach
318
+
319
+ </table>
320
+
321
+ </div>
322
+
323
+ <script>
324
+
325
+ function checkDelete(){
326
+
327
+ if(window.confirm('削除してよろしいですか?')){
328
+
329
+ return true;
330
+
331
+ } else {
332
+
333
+ return false;
334
+
335
+ }
336
+
337
+ }
338
+
339
+ </script>
340
+
341
+ @endsection
342
+
343
+ @endauth
344
+
345
+ @guest
346
+
347
+ <p style="color:blue">管理者用画面です。ログインしてください。</p>
348
+
349
+ @endguest
350
+
351
+
352
+
353
+ ```
242
354
 
243
355
  ### 試したこと
244
356