質問編集履歴

4

ソースコード追加

2017/03/19 01:53

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -283,3 +283,171 @@
283
283
  原因を教えていただきたいです。
284
284
 
285
285
  よろしくお願いします。
286
+
287
+
288
+
289
+ 新規作成のviewです。
290
+
291
+ ```php
292
+
293
+ @extends('layouts.default')
294
+
295
+ @section('title', '新規作成')
296
+
297
+ @section('content')
298
+
299
+
300
+
301
+ @if (session('status'))
302
+
303
+ <div class="alert alert-success" role="alert" onclick="this.classList.add('hidden')">{{ session('status') }}</div>
304
+
305
+ @endif
306
+
307
+
308
+
309
+ <p>{{$message}}</p>
310
+
311
+ <form class="form-horizontal" role="form" method="post" action="{{url('/article')}}">
312
+
313
+ <input type="hidden" name="_token" value="{{csrf_token()}}">
314
+
315
+
316
+
317
+ <!--↓↓名前↓↓-->
318
+
319
+ <div class="form-group">
320
+
321
+ <label for="name" class="control-label col-sm-2">名前:</label>
322
+
323
+ <div class="col-sm-10">
324
+
325
+ <input type="text" name="name" id="name" value="{{ old('name') }}" class="form-control" placeholder="名前を文字を入力してください" autofocus>
326
+
327
+ @if($errors->has('name'))
328
+
329
+ <p class="text-danger" style="margin-bottom: 30px;">{{ $errors->first('name') }}</p>
330
+
331
+ @endif
332
+
333
+ <!--/.col-sm-10--></div>
334
+
335
+ <!--/.form-group--></div>
336
+
337
+ <!--↑↑名前↑↑-->
338
+
339
+
340
+
341
+ <!--↓↓年齢↓↓-->
342
+
343
+ <div class="form-group">
344
+
345
+ <label for="age" class="control-label col-sm-2">年齢:</label>
346
+
347
+ <div class="col-sm-10">
348
+
349
+ <input type="number" name="age" id="age" value="{{ old('age') }}" class="form-control" placeholder="年齢を入力してください" autofocus>
350
+
351
+ @if($errors->has('age'))
352
+
353
+ <p class="text-danger" style="margin-bottom: 30px;">{{ $errors->first('age') }}</p>
354
+
355
+ @endif
356
+
357
+ <!--/.col-sm-10--></div>
358
+
359
+ <!--/.form-group--></div>
360
+
361
+ <!--↑↑年齢↑↑-->
362
+
363
+
364
+
365
+ <button class="btn btn-lg btn-primary btn-block" type="submit">送信</button>
366
+
367
+ </form>
368
+
369
+ @endsection
370
+
371
+ ```
372
+
373
+
374
+
375
+ 更新のviewです。
376
+
377
+ ```php
378
+
379
+ @extends('layouts.default')
380
+
381
+ @section('title', '編集ページ')
382
+
383
+ @section('content')
384
+
385
+
386
+
387
+ <p>{{$message}}</p>
388
+
389
+ <form class="form-horizontal" role="form" method="post" action="{{url('/article',$data->id)}}">
390
+
391
+ <input type="hidden" name="_token" value="{{csrf_token()}}">
392
+
393
+ {{-- 隠しフィールド --}}
394
+
395
+ <input type="hidden" name="_method" value="PATCH">
396
+
397
+
398
+
399
+ <!--↓↓名前↓↓-->
400
+
401
+ <div class="form-group">
402
+
403
+ <label for="name" class="control-label col-sm-2">名前:</label>
404
+
405
+ <div class="col-sm-10">
406
+
407
+ <input type="text" name="name" value="{{ old('name', $data->name) }}" id="name" class="form-control" placeholder="名前を文字を入力してください" autofocus>
408
+
409
+ @if($errors->has('name'))
410
+
411
+ <p class="text-danger" style="margin-bottom: 30px;">{{ $errors->first('name') }}</p>
412
+
413
+ @endif
414
+
415
+ <!--/.col-sm-10--></div>
416
+
417
+ <!--/.form-group--></div>
418
+
419
+ <!--↑↑名前↑↑-->
420
+
421
+
422
+
423
+ <!--↓↓年齢↓↓-->
424
+
425
+ <div class="form-group">
426
+
427
+ <label for="age" class="control-label col-sm-2">年齢:</label>
428
+
429
+ <div class="col-sm-10">
430
+
431
+ <input type="number" name="age" id="age" value="{{ old('age', $data->age) }}" class="form-control" placeholder="年齢を入力してください" autofocus>
432
+
433
+ @if($errors->has('age'))
434
+
435
+ <p class="text-danger" style="margin-bottom: 30px;">{{ $errors->first('age') }}</p>
436
+
437
+ @endif
438
+
439
+ <!--/.col-sm-10--></div>
440
+
441
+ <!--/.form-group--></div>
442
+
443
+ <!--↑↑年齢↑↑-->
444
+
445
+
446
+
447
+ <button class="btn btn-lg btn-primary btn-block" type="submit">送信</button>
448
+
449
+ </form>
450
+
451
+ @endsection
452
+
453
+ ```

3

タイトルの変更

2017/03/19 01:53

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- Laravel5.4でDBデータを追加することが出来な
1
+ Laravel5.4でフォームからDBデータを追加した
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- Laravel 5.4でDB連携を試しているのですが、SELECTとDELETEは出来るのですがINSERTとUPDATEが出来ません
5
+ Laravel 5.4でDB連携を試しているのですが、SELECTとDELETEは出来るのですがINSERTとUPDATEができないので、できるようにしたいです
6
6
 
7
7
 
8
8
 

2

タイトルの変更

2017/03/18 09:23

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- LaravelでDBにデータを追加することが出来ない
1
+ Laravel5.4でDBにデータを追加することが出来ない
test CHANGED
File without changes

1

web\.phpの記述を更新

2017/03/18 08:13

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -268,6 +268,18 @@
268
268
 
269
269
 
270
270
 
271
+ また、web.phpのソースコードは以下の通りです。
272
+
273
+
274
+
275
+ ```php
276
+
277
+ Route::resource('article','ArticleController');
278
+
279
+ ```
280
+
281
+
282
+
271
283
  原因を教えていただきたいです。
272
284
 
273
285
  よろしくお願いします。