質問編集履歴
4
2021/02/26 訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -403,3 +403,11 @@
|
|
403
403
|
|
404
404
|
|
405
405
|
何卒宜しくお願い致します。
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
---2021/02/26 追加
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
現在動作確認で問題ないのは追加処理のみです。
|
3
ソースがおかしい為修正。
test
CHANGED
File without changes
|
test
CHANGED
@@ -286,23 +286,13 @@
|
|
286
286
|
|
287
287
|
const url = '/shop/home/'+ user.id;
|
288
288
|
|
289
|
-
axios.delete(url
|
289
|
+
axios.delete(url, {
|
290
|
-
|
291
|
-
|
290
|
+
|
292
|
-
|
293
|
-
// ...config,
|
294
|
-
|
295
|
-
method: 'delete',
|
296
|
-
|
297
|
-
url: '/shop/home/'+ user.id,
|
298
|
-
|
299
|
-
|
291
|
+
data: { id: user.id }
|
300
|
-
|
301
|
-
|
292
|
+
|
302
|
-
|
293
|
+
|
294
|
+
|
303
|
-
|
295
|
+
}).then(response => {
|
304
|
-
|
305
|
-
|
306
296
|
|
307
297
|
console.log(response);
|
308
298
|
|
2
2021/02/25 route:list 追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,117 +14,127 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
17
|
+
### 該当ソースコード
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
```controller
|
22
|
+
|
23
|
+
<?php
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
namespace App\Http\Controllers\Shop;
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
use App\Http\Controllers\Controller;
|
32
|
+
|
33
|
+
use Illuminate\Http\Request;
|
34
|
+
|
35
|
+
use App\Models\User;
|
36
|
+
|
37
|
+
use Illuminate\Support\Facades\Log;
|
38
|
+
|
39
|
+
use Auth;
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
class HomeController extends Controller
|
44
|
+
|
45
|
+
{
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
public function __construct()
|
50
|
+
|
51
|
+
{
|
52
|
+
|
53
|
+
$this->middleware('auth:shop');
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
~~~~略(削除と編集処理)
|
58
|
+
|
59
|
+
public function destroy(Request $request,User $user)
|
60
|
+
|
61
|
+
{
|
62
|
+
|
63
|
+
Log::info($request->delete);
|
64
|
+
|
65
|
+
$result = $user->delete();
|
66
|
+
|
67
|
+
return ['result' => $result];
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
```web
|
78
|
+
|
79
|
+
<?php
|
80
|
+
|
81
|
+
Route::get('/', function () {
|
82
|
+
|
83
|
+
return view('user/welcome');
|
84
|
+
|
85
|
+
});
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
// ユーザー
|
90
|
+
|
91
|
+
~~~略(ユーザー権限)
|
92
|
+
|
93
|
+
// 管理者
|
94
|
+
|
95
|
+
Route::namespace('Shop')->prefix('shop')->name('shop.')->group(function () {
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
// ログイン認証関連
|
100
|
+
|
101
|
+
Auth::routes([
|
102
|
+
|
103
|
+
'register' => true,
|
104
|
+
|
105
|
+
'confirm' => false,
|
106
|
+
|
107
|
+
'reset' => false
|
108
|
+
|
109
|
+
]);
|
110
|
+
|
111
|
+
// ログイン認証後
|
112
|
+
|
113
|
+
Route::middleware('auth:shop')->group(function () {
|
114
|
+
|
115
|
+
// TOPページ
|
116
|
+
|
117
|
+
// Route::resource('home', 'HomeController', ['only' => 'index']);
|
118
|
+
|
119
|
+
Route::resource('home', 'HomeController')->only(['index', 'store', 'update', 'destroy']);
|
120
|
+
|
121
|
+
});
|
122
|
+
|
123
|
+
});
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
```
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
```vue
|
134
|
+
|
135
|
+
~~~略(上記にbladeの内容を記述)
|
136
|
+
|
137
|
+
|
128
138
|
|
129
139
|
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script>
|
130
140
|
|
@@ -338,343 +348,67 @@
|
|
338
348
|
|
339
349
|
|
340
350
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
use
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
p
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
ret
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
351
|
+
編集と追加は問題ないです。削除のみできないです。
|
352
|
+
|
353
|
+
他にソースが必要の場合や調査の仕方など教えて頂けると幸いです。
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
---2021/02/25 route:list 追加
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
```route:list
|
362
|
+
|
363
|
+
$ php artisan route:list -v
|
364
|
+
|
365
|
+
+--------+-----------+------------------+-------------------+------------------------------------------------------------------------+----------------+
|
366
|
+
|
367
|
+
| Domain | Method | URI | Name | Action | Middleware |
|
368
|
+
|
369
|
+
+--------+-----------+------------------+-------------------+------------------------------------------------------------------------+----------------+
|
370
|
+
|
371
|
+
| | GET|HEAD | / | | Closure | web |
|
372
|
+
|
373
|
+
| | GET|HEAD | api/user | | Closure | api,auth:api |
|
374
|
+
|
375
|
+
| | GET|HEAD | home | user.home.index | App\Http\Controllers\User\HomeController@index | web,auth:user |
|
376
|
+
|
377
|
+
| | GET|HEAD | login | user.login | App\Http\Controllers\User\Auth\LoginController@showLoginForm | web,guest:user |
|
378
|
+
|
379
|
+
| | POST | login | user. | App\Http\Controllers\User\Auth\LoginController@login | web,guest:user |
|
380
|
+
|
381
|
+
| | POST | logout | user.logout | App\Http\Controllers\User\Auth\LoginController@logout | web |
|
382
|
+
|
383
|
+
| | GET|HEAD | register | user.register | App\Http\Controllers\User\Auth\RegisterController@showRegistrationForm | web,guest:user |
|
384
|
+
|
385
|
+
| | POST | register | user. | App\Http\Controllers\User\Auth\RegisterController@register | web,guest:user |
|
386
|
+
|
387
|
+
| | GET|HEAD | shop/home | shop.home.index | App\Http\Controllers\Shop\HomeController@index | web,auth:shop |
|
388
|
+
|
389
|
+
| | POST | shop/home | shop.home.store | App\Http\Controllers\Shop\HomeController@store | web,auth:shop |
|
390
|
+
|
391
|
+
| | PUT|PATCH | shop/home/{home} | shop.home.update | App\Http\Controllers\Shop\HomeController@update | web,auth:shop |
|
392
|
+
|
393
|
+
| | DELETE | shop/home/{home} | shop.home.destroy | App\Http\Controllers\Shop\HomeController@destroy | web,auth:shop |
|
394
|
+
|
395
|
+
| | POST | shop/login | shop. | App\Http\Controllers\Shop\Auth\LoginController@login | web,guest:shop |
|
396
|
+
|
397
|
+
| | GET|HEAD | shop/login | shop.login | App\Http\Controllers\Shop\Auth\LoginController@showLoginForm | web,guest:shop |
|
398
|
+
|
399
|
+
| | POST | shop/logout | shop.logout | App\Http\Controllers\Shop\Auth\LoginController@logout | web |
|
400
|
+
|
401
|
+
| | POST | shop/register | shop. | App\Http\Controllers\Shop\Auth\RegisterController@register | web,guest:shop |
|
402
|
+
|
403
|
+
| | GET|HEAD | shop/register | shop.register | App\Http\Controllers\Shop\Auth\RegisterController@showRegistrationForm | web,guest:shop |
|
404
|
+
|
405
|
+
+--------+-----------+------------------+-------------------+------------------------------------------------------------------------+----------------+
|
396
406
|
|
397
407
|
|
398
408
|
|
399
409
|
```
|
400
410
|
|
401
|
-
|
411
|
+
|
402
|
-
|
403
|
-
<?php
|
404
|
-
|
405
|
-
Route::get('/', function () {
|
406
|
-
|
407
|
-
return view('user/welcome');
|
408
|
-
|
409
|
-
});
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
// ユーザー
|
414
|
-
|
415
|
-
~~~略(ユーザー権限)
|
416
|
-
|
417
|
-
// 管理者
|
418
|
-
|
419
|
-
Route::namespace('Shop')->prefix('shop')->name('shop.')->group(function () {
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
// ログイン認証関連
|
424
|
-
|
425
|
-
Auth::routes([
|
426
|
-
|
427
|
-
'register' => true,
|
428
|
-
|
429
|
-
'confirm' => false,
|
430
|
-
|
431
|
-
'reset' => false
|
432
|
-
|
433
|
-
]);
|
434
|
-
|
435
|
-
// ログイン認証後
|
436
|
-
|
437
|
-
Route::middleware('auth:shop')->group(function () {
|
438
|
-
|
439
|
-
// TOPページ
|
440
|
-
|
441
|
-
// Route::resource('home', 'HomeController', ['only' => 'index']);
|
442
|
-
|
443
|
-
Route::resource('home', 'HomeController')->only(['index', 'store', 'update', 'destroy']);
|
444
|
-
|
445
|
-
});
|
446
|
-
|
447
|
-
});
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
```
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
```vue
|
458
|
-
|
459
|
-
~~~略(上記にbladeの内容を記述)
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script>
|
464
|
-
|
465
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js"></script>
|
466
|
-
|
467
|
-
<script>
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
new Vue({
|
472
|
-
|
473
|
-
el: '#app',
|
474
|
-
|
475
|
-
data: {
|
476
|
-
|
477
|
-
state: 'index',
|
478
|
-
|
479
|
-
params: {
|
480
|
-
|
481
|
-
id: -1,
|
482
|
-
|
483
|
-
name: '',
|
484
|
-
|
485
|
-
email: '',
|
486
|
-
|
487
|
-
password: '',
|
488
|
-
|
489
|
-
passwordConfirmation: ''
|
490
|
-
|
491
|
-
},
|
492
|
-
|
493
|
-
users: [
|
494
|
-
|
495
|
-
// ユーザーデータをJSON化 ④
|
496
|
-
|
497
|
-
@foreach($users as $user)
|
498
|
-
|
499
|
-
{!! $user !!},
|
500
|
-
|
501
|
-
@endforeach
|
502
|
-
|
503
|
-
]
|
504
|
-
|
505
|
-
},
|
506
|
-
|
507
|
-
methods: {
|
508
|
-
|
509
|
-
changeState(state, value) { // 状態を変化させて表示を切り替え ⑤
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
if(state === 'create') {
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
this.params = {
|
518
|
-
|
519
|
-
id: -1,
|
520
|
-
|
521
|
-
name: '',
|
522
|
-
|
523
|
-
email: '',
|
524
|
-
|
525
|
-
password: '',
|
526
|
-
|
527
|
-
passwordConfirmation: ''
|
528
|
-
|
529
|
-
};
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
} else if(state === 'edit') {
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
this.params = value;
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
}
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
this.state = state;
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
},
|
550
|
-
|
551
|
-
onSave() { // データ保存(追加&変更) ⑥
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
const params = this.params;
|
556
|
-
|
557
|
-
let url = '/shop/home';
|
558
|
-
|
559
|
-
let method = 'POST';
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
if(this.state === 'edit') { // 変更の場合
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
url += '/'+ this.params.id;
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
method = 'PUT';
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
}
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
axios({ url, method, params })
|
580
|
-
|
581
|
-
.then(response => {
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
if(response.data.result === true) {
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
location.reload(); // 再読み込み
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
}
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
});
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
},
|
602
|
-
|
603
|
-
onDelete(user) { // データ削除 ⑦
|
604
|
-
|
605
|
-
console.dir(user);
|
606
|
-
|
607
|
-
if(confirm('削除します。よろしいですか?')) {
|
608
|
-
|
609
|
-
console.dir(user);
|
610
|
-
|
611
|
-
const url = '/shop/home/'+ user.id;
|
612
|
-
|
613
|
-
axios.delete(url)
|
614
|
-
|
615
|
-
axios.request({
|
616
|
-
|
617
|
-
// ...config,
|
618
|
-
|
619
|
-
method: 'delete',
|
620
|
-
|
621
|
-
url: '/shop/home/'+ user.id,
|
622
|
-
|
623
|
-
data: { id: user.id }
|
624
|
-
|
625
|
-
})
|
626
|
-
|
627
|
-
.then(response => {
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
console.log(response);
|
632
|
-
|
633
|
-
if(response.data.result === true) {
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
location.reload(); // 再読み込み
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
}
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
});
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
}
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
}
|
654
|
-
|
655
|
-
}
|
656
|
-
|
657
|
-
});
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
</script>
|
662
|
-
|
663
|
-
</body>
|
664
|
-
|
665
|
-
</html>
|
666
|
-
|
667
|
-
@endsection
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
```
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
編集と追加は問題ないです。削除のみできないです。
|
676
|
-
|
677
|
-
他にソースが必要の場合や調査の仕方など教えて頂けると幸いです。
|
678
412
|
|
679
413
|
|
680
414
|
|
1
「他にソースが必要の場合や調査の仕方など教えて頂けると幸いです。」追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -674,4 +674,8 @@
|
|
674
674
|
|
675
675
|
編集と追加は問題ないです。削除のみできないです。
|
676
676
|
|
677
|
+
他にソースが必要の場合や調査の仕方など教えて頂けると幸いです。
|
678
|
+
|
679
|
+
|
680
|
+
|
677
681
|
何卒宜しくお願い致します。
|