質問編集履歴

1

問題点追加

2018/07/03 03:15

投稿

masateru2
masateru2

スコア39

test CHANGED
File without changes
test CHANGED
@@ -157,3 +157,163 @@
157
157
 
158
158
 
159
159
  ```
160
+
161
+
162
+
163
+ 変更後コード
164
+
165
+ ```
166
+
167
+ @extends('layouts.app')
168
+
169
+
170
+
171
+ @section('content')
172
+
173
+ <!doctype html>
174
+
175
+ <html lang="ja">
176
+
177
+ <head>
178
+
179
+ <title>TOP</title>
180
+
181
+ <meta charset="utf-8">
182
+
183
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
184
+
185
+ <meta name="viewport" content="width=device-width, initial-scale=1">
186
+
187
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
188
+
189
+ <title>Top</title>
190
+
191
+ 変更点
192
+
193
+ <script type="text/javascript">
194
+
195
+ $(function(){
196
+
197
+ $(".delete_btn").on("click",function(){
198
+
199
+ $("#delete_id").val($(this).val());
200
+
201
+ });
202
+
203
+ });
204
+
205
+ </script>
206
+
207
+
208
+
209
+ <!-- Fonts -->
210
+
211
+ <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
212
+
213
+ </head>
214
+
215
+ <h1>ブログ一覧</h1>
216
+
217
+
218
+
219
+ @foreach ($articles as $article)
220
+
221
+ <div class="card mb-2">
222
+
223
+ <div class="card-body">
224
+
225
+ <h4 class="card-title">{{ $article->title }}</h4>
226
+
227
+ <h6 class="card-subtitle mb-2 text-muted">{{ $article->updated_at }}</h6>
228
+
229
+ <p class="card-text">{{ $article->body }}</p>
230
+
231
+
232
+
233
+ 変更点
234
+
235
+ <button type="button" class="btn btn-primary delete_btn" data-toggle="modal" data-target="#deleteModal" value="{{ $article->id }}">削除</button>
236
+
237
+ </div>
238
+
239
+ </div>
240
+
241
+ @endforeach
242
+
243
+ <!--DeleteModal-->
244
+
245
+ <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
246
+
247
+ <div class="modal-dialog" role="document">
248
+
249
+ <div class="modal-content">
250
+
251
+ <div class="modal-header">
252
+
253
+ <h5 class="modal-title" id="deleteModalLabel">DeleteConfirmation</h5>
254
+
255
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
256
+
257
+ <span aria-hidden="true">&times;</span>
258
+
259
+ </button>
260
+
261
+ </div>
262
+
263
+ <div class="modal-body">
264
+
265
+ <form method="post" action="/delete">
266
+
267
+ {{ csrf_field() }}
268
+
269
+ 変更点
270
+
271
+ <input type="hidden" class="form-control" name="id" value="" id="delete_id">
272
+
273
+ <div class="form-group">
274
+
275
+ <label for="titleInput">Title</label>
276
+
277
+ <input type="hidden" class="form-control" name="id" value="{{ $article->title }}">
278
+
279
+ </div>
280
+
281
+ <div class="form-group">
282
+
283
+ <label for="bodyInput">Body</label>
284
+
285
+ <textarea readonly class="form-control" id="bodyInput" rows="3" name="body">{{ $article->body }}</textarea>
286
+
287
+ </div>
288
+
289
+ </form>
290
+
291
+ </div>
292
+
293
+ <div class="modal-footer">
294
+
295
+ <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
296
+
297
+ <button type="button" class="btn btn-primary">Delete</button>
298
+
299
+ </div>
300
+
301
+ </div>
302
+
303
+ </div>
304
+
305
+ </div>
306
+
307
+ <!-- CreateModal -->
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+ </html>
316
+
317
+ @endsection
318
+
319
+ ```