質問編集履歴
5
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -144,6 +144,36 @@
|
|
144
144
|
|
145
145
|
```
|
146
146
|
|
147
|
+
LogoutController.php
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
namespace App\Http\Controllers;
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
use Illuminate\Http\Request;
|
156
|
+
|
157
|
+
use Illuminate\Support\Facades\Auth;
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
class LogoutController extends Controller
|
162
|
+
|
163
|
+
{
|
164
|
+
|
165
|
+
public function getLogout(){
|
166
|
+
|
167
|
+
Auth::logout();
|
168
|
+
|
169
|
+
return redirect()->route('login.user');
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
```
|
176
|
+
|
147
177
|
php artisan route:listの結果は以下になります
|
148
178
|
|
149
179
|
```
|
4
質問の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,6 +42,58 @@
|
|
42
42
|
|
43
43
|
```
|
44
44
|
|
45
|
+
use Illuminate\Support\Facades\Route;
|
46
|
+
|
47
|
+
use App\Http\Controllers\Controller;
|
48
|
+
|
49
|
+
use App\Http\Controllers\RegisterController;
|
50
|
+
|
51
|
+
use App\Http\Controllers\LoginController;
|
52
|
+
|
53
|
+
use App\Http\Controllers\LogoutController;
|
54
|
+
|
55
|
+
use App\Http\Controllers\CustomerController;
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
//トップページ
|
60
|
+
|
61
|
+
Route::get('/', 'App\Http\Controllers\CustomerController@index');
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
//フォーム入力ページ(フォームトップページ)
|
66
|
+
|
67
|
+
Route::get('/contact', 'App\Http\Controllers\ContactController@contact_top') -> name('contact.top');
|
68
|
+
|
69
|
+
//確認ページ
|
70
|
+
|
71
|
+
Route::post('/contact/confirm', 'App\Http\Controllers\ContactController@confirm') -> name('contact.confirm');
|
72
|
+
|
73
|
+
//送信完了ページ
|
74
|
+
|
75
|
+
Route::post('/contact/thanks', 'App\Http\Controllers\ContactController@send') -> name('contact.send');
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
//新規ユーザー登録
|
80
|
+
|
81
|
+
Route::get('/register', 'App\Http\Controllers\RegisterController@register') -> name('register.user');
|
82
|
+
|
83
|
+
Route::post('/create', 'App\Http\Controllers\RegisterController@create') -> name('register.create');
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
//ログイン
|
88
|
+
|
89
|
+
Route::get('/login', 'App\Http\Controllers\LoginController@login') -> name('login.user');
|
90
|
+
|
91
|
+
Route::post('/login_user', 'App\Http\Controllers\LoginController@login_user') -> name('login.create');
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
//ログアウト機能
|
96
|
+
|
45
97
|
Route::get('/logout',[
|
46
98
|
|
47
99
|
'uses' => 'App\Http\Controllers\LogoutController@getLogout',
|
@@ -50,35 +102,7 @@
|
|
50
102
|
|
51
103
|
]);
|
52
104
|
|
53
|
-
|
105
|
+
|
54
|
-
|
55
|
-
LogoutController.php
|
56
|
-
|
57
|
-
```
|
58
|
-
|
59
|
-
namespace App\Http\Controllers;
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
use Illuminate\Http\Request;
|
64
|
-
|
65
|
-
use Illuminate\Support\Facades\Auth;
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
class LogoutController extends Controller
|
70
|
-
|
71
|
-
{
|
72
|
-
|
73
|
-
public function getLogout(){
|
74
|
-
|
75
|
-
Auth::logout();
|
76
|
-
|
77
|
-
return redirect()->route('login.user');
|
78
|
-
|
79
|
-
}
|
80
|
-
|
81
|
-
}
|
82
106
|
|
83
107
|
|
84
108
|
|
3
質問の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -17,6 +17,22 @@
|
|
17
17
|
単純にログアウト機能で普通にルートを作成しようとすると、not definedになってしまいます。
|
18
18
|
|
19
19
|
nameでルートの名前をつけてはいるのですが、他のルートとは違ってnot definedになります。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
また、http://127.0.0.1:8000/のトップ画面(index.blade.php)でaタグでログアウト機能を表示しているからか、http://127.0.0.1:8000/でページを開こうとすると、not definedになります。
|
24
|
+
|
25
|
+
しかし、index.blade.phpの
|
26
|
+
|
27
|
+
<li><a href="{{ route('user.logout') }}">ログアウト</a></li>
|
28
|
+
|
29
|
+
を削除することで、トップ画面を表示できるようになります。
|
30
|
+
|
31
|
+
なぜログアウトのrouteだけnot definedになるのかがわかりません。
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
20
36
|
|
21
37
|
|
22
38
|
|
2
php artisan route:listの内容
test
CHANGED
File without changes
|
test
CHANGED
@@ -104,6 +104,44 @@
|
|
104
104
|
|
105
105
|
```
|
106
106
|
|
107
|
+
php artisan route:listの結果は以下になります
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
+--------+----------+-----------------+-----------------------------+----------------------------------------------------+------------+
|
112
|
+
|
113
|
+
| Domain | Method | URI | Name | Action | Middleware |
|
114
|
+
|
115
|
+
+--------+----------+-----------------+-----------------------------+----------------------------------------------------+------------+
|
116
|
+
|
117
|
+
| | GET|HEAD | / | generated::VTdxw3AoE6i1sxUl | App\Http\Controllers\CustomerController@index | web |
|
118
|
+
|
119
|
+
| | GET|HEAD | api/user | generated::JckwSXsWFxdD2V82 | Closure | api |
|
120
|
+
|
121
|
+
| | | | | | auth:api |
|
122
|
+
|
123
|
+
| | GET|HEAD | contact | contact.top | App\Http\Controllers\ContactController@contact_top | web |
|
124
|
+
|
125
|
+
| | POST | contact/confirm | contact.confirm | App\Http\Controllers\ContactController@confirm | web |
|
126
|
+
|
127
|
+
| | POST | contact/thanks | contact.send | App\Http\Controllers\ContactController@send | web |
|
128
|
+
|
129
|
+
| | POST | create | register.create | App\Http\Controllers\RegisterController@create | web |
|
130
|
+
|
131
|
+
| | GET|HEAD | login | login.user | App\Http\Controllers\LoginController@login | web |
|
132
|
+
|
133
|
+
| | POST | login_user | login.create | App\Http\Controllers\LoginController@login_user | web |
|
134
|
+
|
135
|
+
| | GET|HEAD | mypage/{id} | mypage | App\Http\Controllers\MypageController@get_user | web |
|
136
|
+
|
137
|
+
| | | | | | auth |
|
138
|
+
|
139
|
+
| | GET|HEAD | register | register.user | App\Http\Controllers\RegisterController@register | web |
|
140
|
+
|
141
|
+
+--------+----------+-----------------+-----------------------------+----------------------------------------------------+------------+
|
142
|
+
|
143
|
+
```
|
144
|
+
|
107
145
|
|
108
146
|
|
109
147
|
### 試したこと
|
1
文末の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -114,6 +114,10 @@
|
|
114
114
|
|
115
115
|
|
116
116
|
|
117
|
+
ご教授お願いいたします。
|
118
|
+
|
119
|
+
|
120
|
+
|
117
121
|
### 補足情報(FW/ツールのバージョンなど)
|
118
122
|
|
119
123
|
Laravel Framework 8.54.0
|