質問編集履歴

2

誤字

2019/01/27 07:32

投稿

oxyu8
oxyu8

スコア23

test CHANGED
File without changes
test CHANGED
@@ -138,11 +138,13 @@
138
138
 
139
139
  ```
140
140
 
141
+ web.php
142
+
141
143
 
142
144
 
143
145
  <?php
144
146
 
145
- web.php
147
+
146
148
 
147
149
 
148
150
 
@@ -296,7 +298,9 @@
296
298
 
297
299
  ```
298
300
 
301
+ ```
302
+
299
- 2019_01_25_050924_create_user_table.php```
303
+ 2019_01_25_050924_create_user_table.php
300
304
 
301
305
 
302
306
 

1

問題解決に必要なコードが抜けていた

2019/01/27 07:32

投稿

oxyu8
oxyu8

スコア23

test CHANGED
File without changes
test CHANGED
@@ -22,6 +22,8 @@
22
22
 
23
23
  このエラーが発生した場合ルーティングの部分が間違っている可能性が高いと調べたのですが、どの部分が間違っているのか自分で見つけることが出来ません。
24
24
 
25
+ またデータベースにも反映されません。データベースはsqliteを使用しています
26
+
25
27
 
26
28
 
27
29
  よろしくお願いします。
@@ -34,7 +36,13 @@
34
36
 
35
37
 
36
38
 
39
+ ```
40
+
41
+ UserController.php
42
+
43
+
44
+
37
- ```<?php
45
+ <?php
38
46
 
39
47
 
40
48
 
@@ -130,302 +138,480 @@
130
138
 
131
139
  ```
132
140
 
141
+
142
+
133
143
  <?php
134
144
 
135
-
145
+ web.php
146
+
147
+
148
+
136
-
149
+ /*
150
+
151
+ |--------------------------------------------------------------------------
152
+
153
+ | Web Routes
154
+
155
+ |--------------------------------------------------------------------------
156
+
157
+ |
158
+
159
+ | Here is where you can register web routes for your application. These
160
+
161
+ | routes are loaded by the RouteServiceProvider within a group which
162
+
163
+ | contains the "web" middleware group. Now create something great!
164
+
165
+ |
166
+
167
+ */
168
+
169
+
170
+
171
+ Route::get('/', function () {
172
+
173
+ return view('welcome');
174
+
175
+ });
176
+
177
+
178
+
179
+ /*Route::get('user/signup', 'UserController@getSignup');
180
+
181
+ Route::post('user/signup', 'UserController@postSignup');
182
+
183
+ Route::get('user/profile', 'UserController@getProfile');*/
184
+
185
+
186
+
187
+
188
+
189
+ Route::group(['prefix' => 'user'], function() {
190
+
191
+
192
+
193
+ Route::get('/signup',[
194
+
195
+ 'uses' => 'UserController@getSignup',
196
+
197
+ 'as' => 'user.signup'
198
+
199
+ ]);
200
+
201
+
202
+
203
+ Route::post('/signup',[
204
+
205
+ 'uses' => 'UserController@postSignup',
206
+
207
+ 'as' => 'user.signup'
208
+
209
+ ]);
210
+
211
+
212
+
213
+ Route::post('/profile',[
214
+
215
+ 'uses' => 'UserController@getProfile',
216
+
217
+ 'as' => 'user.profile'
218
+
219
+ ]);
220
+
221
+
222
+
223
+ });
224
+
225
+
226
+
227
+ ```
228
+
229
+
230
+
231
+ ```
232
+
233
+ User.php
234
+
235
+
236
+
237
+ <?php
238
+
239
+
240
+
137
- namespace App\Http\Controllers;
241
+ namespace App;
138
-
139
-
140
-
242
+
243
+
244
+
141
- use Illuminate\Http\Request;
245
+ use Illuminate\Database\Eloquent\Model;
142
-
246
+
143
- use App\User;
247
+ use Illuminate\Notifications\Notifiable;
248
+
144
-
249
+ use Illuminate\Foundation\Auth\User as Authenticatable;
145
-
146
-
250
+
251
+
252
+
147
- class UserController extends Controller
253
+ class User extends Authenticatable
148
254
 
149
255
  {
150
256
 
257
+ use Notifiable;
258
+
259
+
260
+
261
+ /**
262
+
263
+ * The attributes that are mass assignable.
264
+
265
+ *
266
+
267
+ * @var array
268
+
269
+ */
270
+
271
+ protected $fillable = [
272
+
273
+ 'name', 'namek','address', 'birth', 'mail', 'password',
274
+
275
+ ];
276
+
277
+
278
+
279
+ /**
280
+
281
+ * The attributes that should be hidden for arrays.
282
+
283
+ *
284
+
285
+ * @var array
286
+
287
+ */
288
+
289
+ protected $hidden = [
290
+
291
+ 'id', //'remember_token',
292
+
293
+ ];
294
+
295
+ }
296
+
297
+ ```
298
+
299
+ 2019_01_25_050924_create_user_table.php```
300
+
301
+
302
+
303
+ <?php
304
+
305
+
306
+
307
+ use Illuminate\Support\Facades\Schema;
308
+
309
+ use Illuminate\Database\Schema\Blueprint;
310
+
311
+ use Illuminate\Database\Migrations\Migration;
312
+
313
+
314
+
315
+ class CreateUserTable extends Migration
316
+
317
+ {
318
+
319
+ /**
320
+
321
+ * Run the migrations.
322
+
323
+ *
324
+
325
+ * @return void
326
+
327
+ */
328
+
151
- public function getSignup(){
329
+ public function up()
330
+
152
-
331
+ {
332
+
333
+ Schema::create('user', function (Blueprint $table) {
334
+
335
+ $table->increments('id');
336
+
337
+ $table->timestamps();
338
+
339
+ $table->string('name');
340
+
341
+ $table->string('namek');
342
+
153
- return view('user.signup');
343
+ $table->string('address');
344
+
345
+ $table->string('birth');
346
+
347
+ $table->string('mail');
348
+
349
+ $table->string('password');
350
+
351
+
352
+
353
+ });
154
354
 
155
355
  }
156
356
 
157
357
 
158
358
 
359
+ /**
360
+
361
+ * Reverse the migrations.
362
+
363
+ *
364
+
365
+ * @return void
366
+
367
+ */
368
+
159
- public function postSignup(Request $request){
369
+ public function down()
160
-
161
- $this->validate($request,[
370
+
162
-
163
- 'name' => 'required',
164
-
165
- 'namek' => 'required',
166
-
167
- 'mail' => 'email|required|unique:users',
168
-
169
- 'password' => 'required|min:4',
170
-
171
- 'address' => 'required',
172
-
173
- 'birth' => 'required',
174
-
175
- ]);
371
+ {
176
-
177
-
178
-
179
-
180
-
181
- $user = new User([
372
+
182
-
183
- 'name' => $request->input('name'),
184
-
185
- 'namek' => $request->input('namek'),
186
-
187
- 'address' => $request->input('address'),
188
-
189
- 'birth' => $request->input('birth'),
190
-
191
- 'mail' => $request->input('mail'),
192
-
193
- 'password' => bcrypt($request->input('password')),
194
-
195
-
196
-
197
- ]);
198
-
199
-
200
-
201
- $user->save();
202
-
203
-
204
-
205
- return redirect()->route('user.profile');
373
+ Schema::dropIfExists('user');
206
-
207
-
208
-
374
+
209
- }
375
+ }
210
-
211
-
212
-
213
- public function getProfile(){
214
-
215
- return view('user.profile');
216
-
217
- }
218
376
 
219
377
  }
220
378
 
221
-
222
-
223
- ```
224
-
225
-
226
-
227
- ```<?php
228
-
229
-
230
-
231
- namespace App;
232
-
233
-
234
-
235
- use Illuminate\Database\Eloquent\Model;
236
-
237
- use Illuminate\Notifications\Notifiable;
238
-
239
- use Illuminate\Foundation\Auth\User as Authenticatable;
240
-
241
-
242
-
243
- class User extends Authenticatable
244
-
245
- {
246
-
247
- use Notifiable;
248
-
249
-
250
-
251
- /**
252
-
253
- * The attributes that are mass assignable.
254
-
255
- *
256
-
257
- * @var array
258
-
259
- */
260
-
261
- protected $fillable = [
262
-
263
- 'name', 'namek','address', 'birth', 'mail', 'password',
264
-
265
- ];
266
-
267
-
268
-
269
- /**
270
-
271
- * The attributes that should be hidden for arrays.
272
-
273
- *
274
-
275
- * @var array
276
-
277
- */
278
-
279
- protected $hidden = [
280
-
281
- 'id', //'remember_token',
282
-
283
- ];
284
-
285
- }
286
-
287
- ```
288
-
289
-
290
-
291
- ```
292
-
293
- <?php
294
-
295
-
296
-
297
- namespace App;
298
-
299
-
300
-
301
- use Illuminate\Database\Eloquent\Model;
302
-
303
- use Illuminate\Notifications\Notifiable;
304
-
305
- use Illuminate\Foundation\Auth\User as Authenticatable;
306
-
307
-
308
-
309
- class User extends Authenticatable
310
-
311
- {
312
-
313
- use Notifiable;
314
-
315
-
316
-
317
- /**
318
-
319
- * The attributes that are mass assignable.
320
-
321
- *
322
-
323
- * @var array
324
-
325
- */
326
-
327
- protected $fillable = [
328
-
329
- 'name', 'namek','address', 'birth', 'mail', 'password',
330
-
331
- ];
332
-
333
-
334
-
335
- /**
336
-
337
- * The attributes that should be hidden for arrays.
338
-
339
- *
340
-
341
- * @var array
342
-
343
- */
344
-
345
- protected $hidden = [
346
-
347
- 'id', //'remember_token',
348
-
349
- ];
350
-
351
- }
352
-
353
- ```
354
-
355
- ```<?php
356
-
357
-
358
-
359
- use Illuminate\Support\Facades\Schema;
360
-
361
- use Illuminate\Database\Schema\Blueprint;
362
-
363
- use Illuminate\Database\Migrations\Migration;
364
-
365
-
366
-
367
- class CreateUserTable extends Migration
368
-
369
- {
370
-
371
- /**
372
-
373
- * Run the migrations.
374
-
375
- *
376
-
377
- * @return void
378
-
379
- */
380
-
381
- public function up()
382
-
383
- {
384
-
385
- Schema::create('user', function (Blueprint $table) {
386
-
387
- $table->increments('id');
388
-
389
- $table->timestamps();
390
-
391
- $table->string('name');
392
-
393
- $table->string('namek');
394
-
395
- $table->string('address');
396
-
397
- $table->string('birth');
398
-
399
- $table->string('mail');
400
-
401
- $table->string('password');
402
-
403
-
404
-
405
- });
406
-
407
- }
408
-
409
-
410
-
411
- /**
412
-
413
- * Reverse the migrations.
414
-
415
- *
416
-
417
- * @return void
418
-
419
- */
420
-
421
- public function down()
422
-
423
- {
424
-
425
- Schema::dropIfExists('user');
426
-
427
- }
428
-
429
- }
430
-
431
- ```
379
+ ```
380
+
381
+
382
+
383
+ ```
384
+
385
+ master_auth.blade.php
386
+
387
+
388
+
389
+ <!DOCTYPE HTML>
390
+
391
+ <html lang="ja">
392
+
393
+ <head>
394
+
395
+ <meta charset="utf-8">
396
+
397
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
398
+
399
+ <meta name="viewport" content="width=device-width, initial-scale=1">
400
+
401
+ <title>@yield('title')</title>
402
+
403
+ <link href="{{ url('/') }}/dist/css/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"><!-- Loading Bootstrap -->
404
+
405
+ <link href="{{ url('/') }}/dist/css/flat-ui.min.css" rel="stylesheet"><!-- Loading Flat UI -->
406
+
407
+ <link href="{{ url('/') }}/css/starter-template.css" rel="stylesheet"><!--Bootstrap theme(Starter)-->
408
+
409
+
410
+
411
+ <link rel="shortcut icon" href="{{ url('/') }}/dist/img/favicon.ico">
412
+
413
+
414
+
415
+ <!--[if lt IE 9]>
416
+
417
+ <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
418
+
419
+ <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
420
+
421
+ <![endif]-->
422
+
423
+ @yield('styles')
424
+
425
+ </head>
426
+
427
+ <body>
428
+
429
+ @include('partials.header')
430
+
431
+ <div class="container">
432
+
433
+ @yield('content')
434
+
435
+ </div><!-- /.container -->
436
+
437
+
438
+
439
+ <footer class="footer">
440
+
441
+ <div class="container">
442
+
443
+ <p class="text-muted">認証デモ</p>
444
+
445
+ </div>
446
+
447
+ </footer>
448
+
449
+
450
+
451
+ <!-- Bootstrap core JavaScript
452
+
453
+ ================================================== -->
454
+
455
+ <script src="{{ url('/') }}/dist/js/vendor/jquery.min.js"></script>
456
+
457
+ <script src="{{ url('/') }}/dist/js/vendor/video.js"></script>
458
+
459
+ <script src="{{ url('/') }}/dist/js/flat-ui.min.js"></script>
460
+
461
+
462
+
463
+ <script src="{{ url('/') }}/assets/js/prettify.js"></script>
464
+
465
+ <script src="{{ url('/') }}/assets/js/application.js"></script>
466
+
467
+
468
+
469
+ @yield('scripts')
470
+
471
+ </body>
472
+
473
+ </html>
474
+
475
+ ```
476
+
477
+
478
+
479
+ ```
480
+
481
+ signup.blade.php
482
+
483
+
484
+
485
+ @extends('layouts.master_auth')
486
+
487
+
488
+
489
+ @section('content')
490
+
491
+ <div class="row">
492
+
493
+ <form action= "/touroku/public/user/profile" method="post" class="form-horizontal" style="margin-top: 50px;">
494
+
495
+ <div class="form-group">
496
+
497
+ <label class="col-sm-3 control-label" for="InputName">氏名</label>
498
+
499
+ <div class="col-sm-9">
500
+
501
+ <input type="text" name="name" class="form-control" id="InputName" placeholder="氏名">
502
+
503
+ <!--/.col-sm-10---></div>
504
+
505
+ <!--/form-group--></div>
506
+
507
+
508
+
509
+ <div class="form-group">
510
+
511
+ <label class="col-sm-3 control-label" for="InputNamek">氏名(カタカナ)</label>
512
+
513
+ <div class="col-sm-9">
514
+
515
+ <input type="" name="namek" class="form-control" id="InputNamek" placeholder="">
516
+
517
+ </div>
518
+
519
+ <!--/form-group--></div>
520
+
521
+
522
+
523
+ <div class="form-group">
524
+
525
+ <label class="col-sm-3 control-label" for="InputAddress">住所</label>
526
+
527
+ <div class="col-sm-9">
528
+
529
+ <input type="" name="address" class="form-control" id="InputAddress" placeholder="番地まで">
530
+
531
+ </div>
532
+
533
+ <!--/form-group--></div>
534
+
535
+
536
+
537
+ <div class="form-group">
538
+
539
+ <label class="col-sm-3 control-label" for="InputBirth">生年月日</label>
540
+
541
+ <div class="col-sm-9">
542
+
543
+ <input type="" name="birth" class="form-control" id="InputBirth" placeholder="">
544
+
545
+ </div>
546
+
547
+ <!--/form-group--></div>
548
+
549
+
550
+
551
+ <div class="form-group">
552
+
553
+ <label class="col-sm-3 control-label" for="InputEmail">メール・アドレス</label>
554
+
555
+ <div class="col-sm-9">
556
+
557
+ <input type="email" name="mail" class="form-control" id="InputMail" placeholder="">
558
+
559
+ </div>
560
+
561
+ <!--/form-group--></div>
562
+
563
+
564
+
565
+ <div class="form-group">
566
+
567
+ <label class="col-sm-3 control-label" for="InputPassword">パスワード</label>
568
+
569
+ <div class="col-sm-9">
570
+
571
+ <input type="password" name="password" class="form-control" id="InputPassword" placeholder="">
572
+
573
+ </div>
574
+
575
+ <!--/form-group--></div>
576
+
577
+
578
+
579
+ <div class="form-group">
580
+
581
+ <div class="col-sm-offset-3 col-sm-9">
582
+
583
+ <button type="submit" class="btn btn-primary btn-block">新規登録</button>
584
+
585
+ </div>
586
+
587
+ <!--/form-group--></div>
588
+
589
+ {{ csrf_field() }}
590
+
591
+ </form>
592
+
593
+ </div>
594
+
595
+ @endsection
596
+
597
+ ```
598
+
599
+
600
+
601
+ ```
602
+
603
+ profile.blade.php
604
+
605
+
606
+
607
+ @extends('layouts.master_auth')
608
+
609
+
610
+
611
+ @section('content')
612
+
613
+ <div style="margin-top: 30px; text-align: center;"><h3>新規登録完了しました。</h3></div>
614
+
615
+ @endsection
616
+
617
+ ```