質問編集履歴

2

web.phpの記載

2020/09/01 05:12

投稿

Yuu412
Yuu412

スコア37

test CHANGED
File without changes
test CHANGED
@@ -20,6 +20,176 @@
20
20
 
21
21
 
22
22
 
23
+ ```web.php
24
+
25
+ <?php
26
+
27
+
28
+
29
+ use App\Laboratory;
30
+
31
+ use Illuminate\Http\Request;
32
+
33
+
34
+
35
+ Auth::routes(); //認証機能を使用する。
36
+
37
+
38
+
39
+ Route::get('register/verify/{token}', 'Auth\RegisterController@showForm');
40
+
41
+
42
+
43
+ Route::post('register/main_check', 'Auth\RegisterController@mainCheck')->name('register.main.check');
44
+
45
+ Route::post('register/main_register', 'Auth\RegisterController@mainRegister')->name('register.main.registered');
46
+
47
+
48
+
49
+ Route::get('/home', 'LabController@index')->name('home');
50
+
51
+
52
+
53
+ Route::get('/review/{token}', 'LinkController@qr_to_add');
54
+
55
+
56
+
57
+ Route::group(['middleware' => ['web']], function ()
58
+
59
+ {
60
+
61
+
62
+
63
+ Route::post('register/pre_check', 'Auth\RegisterController@pre_check')->name('register.pre_check');
64
+
65
+
66
+
67
+ Route::get('/', 'LabController@index');
68
+
69
+ Route::post('/', 'LabController@index');
70
+
71
+
72
+
73
+ Route::get('/search_result', 'LabController@search');
74
+
75
+
76
+
77
+ Route::get('/area/{pre_name}','LabController@area_search');
78
+
79
+
80
+
81
+ Route::get('/faculty_result/{faculty}', 'LabController@faculty_result');
82
+
83
+
84
+
85
+ Route::post('/laboratories', 'LabController@store');
86
+
87
+
88
+
89
+ Route::post('/add/2', 'LabController@ret_univ');
90
+
91
+
92
+
93
+ Route::post('/laboratory/{laboratory}', 'LabController@store_evaluation');
94
+
95
+
96
+
97
+ Route::post('/', 'LabController@mv_add');
98
+
99
+
100
+
101
+ Route::post('/labedit/{lab_evaluation_id}','LabController@mv_update');
102
+
103
+
104
+
105
+ Route::post('/mypage/update', 'LabController@update');
106
+
107
+
108
+
109
+ Route::delete('/mypage/delete/{lab_evaluation_id}', 'LabController@delete');
110
+
111
+
112
+
113
+ Route::PUT('update',[
114
+
115
+ 'uses' => 'UserController@update',
116
+
117
+ 'as' => 'update'
118
+
119
+ ]);
120
+
121
+
122
+
123
+
124
+
125
+ Route::get('/add', 'LinkController@to_add');
126
+
127
+
128
+
129
+ Route::POST('/add_evaluation', 'LabController@add_evaluation');
130
+
131
+
132
+
133
+ Route::GET('/add_evaluation', function()
134
+
135
+ {
136
+
137
+ return view('add_evaluation');
138
+
139
+ });
140
+
141
+
142
+
143
+ Route::get('/add_evaluation/{lab_details_univ}/{lab_details_lab}', 'LinkController@to_add_evaluation');
144
+
145
+
146
+
147
+ Route::get('/univ/{univ_name}','LinkController@to_univ');
148
+
149
+
150
+
151
+ Route::get('/lab/{lab_details_univ}/{lab_details_lab}','LinkController@to_lab_details');
152
+
153
+
154
+
155
+ Route::get('/lab-evaluation/{lab_evaluation_details}','LinkController@to_lab_evaluation_details');
156
+
157
+
158
+
159
+ Route::get('/mypage','LinkController@to_mypage');
160
+
161
+
162
+
163
+
164
+
165
+ Route::get('/confirm_user',[
166
+
167
+ 'uses' => 'UserController@confirm_user',
168
+
169
+ 'as' => 'confirm'
170
+
171
+ ]);
172
+
173
+
174
+
175
+ Route::get('/edit_user','UserController@edit_user');
176
+
177
+
178
+
179
+
180
+
181
+ Route::get('/scraping','ScrapingController@scraping');
182
+
183
+
184
+
185
+ });
186
+
187
+ ```
188
+
189
+
190
+
191
+
192
+
23
193
  ---
24
194
 
25
195
 

1

解決策の候補の提示とその補足のお願い

2020/09/01 05:12

投稿

Yuu412
Yuu412

スコア37

test CHANGED
File without changes
test CHANGED
@@ -17,3 +17,99 @@
17
17
 
18
18
 
19
19
  ご回答よろしくお願いいたします。
20
+
21
+
22
+
23
+ ---
24
+
25
+
26
+
27
+ 調べたところ、[こちらのサイトで](https://qiita.com/zaburo/items/9fcf0f4c771e011a4d35)
28
+
29
+ ```Authenticate.php
30
+
31
+ <?php
32
+
33
+
34
+
35
+ namespace App\Http\Middleware;
36
+
37
+
38
+
39
+ use Illuminate\Auth\Middleware\Authenticate as Middleware;
40
+
41
+
42
+
43
+ class Authenticate extends Middleware
44
+
45
+ {
46
+
47
+ /**
48
+
49
+ * Get the path the user should be redirected to when they are not authenticated.
50
+
51
+ *
52
+
53
+ * @param \Illuminate\Http\Request $request
54
+
55
+ * @return string|null
56
+
57
+ */
58
+
59
+ protected function redirectTo($request)
60
+
61
+ {
62
+
63
+ if (! $request->expectsJson()) {
64
+
65
+ return route('login');
66
+
67
+ }
68
+
69
+ }
70
+
71
+ }
72
+
73
+
74
+
75
+ ```
76
+
77
+
78
+
79
+ ここで、認証のないアカウントのリダイレクト処理が行われていると書いていました。
80
+
81
+
82
+
83
+ Auth::route()からいろいろ経由してここに飛んでくるみたいなのですが、ここでの引数($request)とは一体なにを指すのでしょうか?
84
+
85
+
86
+
87
+ もし、Authenticate.phpで
88
+
89
+ ```条件分岐
90
+
91
+ protected function redirectTo($request)
92
+
93
+ {
94
+
95
+ if(ある特定のパスにアクセスがあったとき){
96
+
97
+ ある特定のページにリダイレクトする。
98
+
99
+ }
100
+
101
+ //それ以外は
102
+
103
+ elseif (! $request->expectsJson()) {
104
+
105
+ return route('login');
106
+
107
+ }
108
+
109
+ }
110
+
111
+ ```
112
+
113
+
114
+
115
+ このような形で、ある特定ページにのみ認証なしでアクセスすることは可能でしょうか。