質問編集履歴
2
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,11 +6,21 @@
|
|
6
6
|
|
7
7
|
```
|
8
8
|
|
9
|
-
#
|
10
|
-
|
11
|
-
#
|
12
|
-
|
13
|
-
#
|
9
|
+
#46 C:\Users\sk\programming\laravel\travel_app_2\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(163): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
|
10
|
+
|
11
|
+
#47 C:\Users\sk\programming\laravel\travel_app_2\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
|
12
|
+
|
13
|
+
#48 C:\Users\sk\programming\laravel\travel_app_2\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
|
14
|
+
|
15
|
+
#49 C:\Users\sk\programming\laravel\travel_app_2\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
|
16
|
+
|
17
|
+
#50 C:\Users\sk\programming\laravel\travel_app_2\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
|
18
|
+
|
19
|
+
#51 C:\Users\sk\programming\laravel\travel_app_2\public\index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
|
20
|
+
|
21
|
+
#52 C:\Users\sk\programming\laravel\travel_app_2\server.php(21): require_once('C:\\Users\\sk\\pro...')
|
22
|
+
|
23
|
+
#53 {main}
|
14
24
|
|
15
25
|
"}
|
16
26
|
|
1
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -15,3 +15,293 @@
|
|
15
15
|
"}
|
16
16
|
|
17
17
|
```
|
18
|
+
|
19
|
+
php artisan route:list
|
20
|
+
|
21
|
+
```
|
22
|
+
|
23
|
+
+--------+-----------+---------------------------------+------------------+------------------------------------------------------------------------+--------------+
|
24
|
+
|
25
|
+
| Domain | Method | URI | Name | Action
|
26
|
+
|
27
|
+
| Middleware |
|
28
|
+
|
29
|
+
+--------+-----------+---------------------------------+------------------+------------------------------------------------------------------------+--------------+
|
30
|
+
|
31
|
+
| | GET|HEAD | / | | App\Http\Controllers\ArticlesController@index
|
32
|
+
|
33
|
+
| web |
|
34
|
+
|
35
|
+
| | GET|HEAD | api/user | | Closure
|
36
|
+
|
37
|
+
| api,auth:api |
|
38
|
+
|
39
|
+
| | GET|HEAD | articles | articles.index | App\Http\Controllers\ArticlesController@index
|
40
|
+
|
41
|
+
| web |
|
42
|
+
|
43
|
+
| | POST | articles | articles.store | App\Http\Controllers\ArticlesController@store
|
44
|
+
|
45
|
+
| web |
|
46
|
+
|
47
|
+
| | GET|HEAD | articles/create | articles.create | App\Http\Controllers\ArticlesController@create
|
48
|
+
|
49
|
+
| web |
|
50
|
+
|
51
|
+
| | GET|HEAD | articles/daily_index | | App\Http\Controllers\ArticlesController@daily_index
|
52
|
+
|
53
|
+
| web |
|
54
|
+
|
55
|
+
| | GET|HEAD | articles/new_arrivals_index | | App\Http\Controllers\ArticlesController@new_arrivals_index
|
56
|
+
|
57
|
+
| web |
|
58
|
+
|
59
|
+
| | PUT|PATCH | articles/{article} | articles.update | App\Http\Controllers\ArticlesController@update
|
60
|
+
|
61
|
+
| web |
|
62
|
+
|
63
|
+
| | GET|HEAD | articles/{article} | articles.show | App\Http\Controllers\ArticlesController@show
|
64
|
+
|
65
|
+
| web |
|
66
|
+
|
67
|
+
| | DELETE | articles/{article} | articles.destroy | App\Http\Controllers\ArticlesController@destroy
|
68
|
+
|
69
|
+
| web |
|
70
|
+
|
71
|
+
| | GET|HEAD | articles/{article}/edit | articles.edit | App\Http\Controllers\ArticlesController@edit
|
72
|
+
|
73
|
+
| web |
|
74
|
+
|
75
|
+
| | GET|HEAD | home | home | App\Http\Controllers\HomeController@index
|
76
|
+
|
77
|
+
| web,auth |
|
78
|
+
|
79
|
+
| | POST | login | | App\Http\Controllers\Auth\LoginController@login
|
80
|
+
|
81
|
+
| web,guest |
|
82
|
+
|
83
|
+
| | GET|HEAD | login | login | App\Http\Controllers\Auth\LoginController@showLoginForm
|
84
|
+
|
85
|
+
| web,guest |
|
86
|
+
|
87
|
+
| | POST | logout | logout | App\Http\Controllers\Auth\LoginController@logout
|
88
|
+
|
89
|
+
| web |
|
90
|
+
|
91
|
+
| | POST | password/email | password.email | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail | web,guest |
|
92
|
+
|
93
|
+
| | GET|HEAD | password/reset | password.request | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest |
|
94
|
+
|
95
|
+
| | POST | password/reset | password.update | App\Http\Controllers\Auth\ResetPasswordController@reset
|
96
|
+
|
97
|
+
| web,guest |
|
98
|
+
|
99
|
+
| | GET|HEAD | password/reset/{token} | password.reset | App\Http\Controllers\Auth\ResetPasswordController@showResetForm | web,guest |
|
100
|
+
|
101
|
+
| | POST | register | | App\Http\Controllers\Auth\RegisterController@register
|
102
|
+
|
103
|
+
| web,guest |
|
104
|
+
|
105
|
+
| | GET|HEAD | register | register | App\Http\Controllers\Auth\RegisterController@showRegistrationForm | web,guest |
|
106
|
+
|
107
|
+
| | POST | tags | tags.store | App\Http\Controllers\TagsController@store
|
108
|
+
|
109
|
+
| web |
|
110
|
+
|
111
|
+
| | GET|HEAD | tags | tags.index | App\Http\Controllers\TagsController@index
|
112
|
+
|
113
|
+
| web |
|
114
|
+
|
115
|
+
| | GET|HEAD | tags/create | tags.create | App\Http\Controllers\TagsController@create
|
116
|
+
|
117
|
+
| web |
|
118
|
+
|
119
|
+
| | GET|HEAD | tags/{tag_id}/tag_article_index | | App\Http\Controllers\TagsController@tag_article_index
|
120
|
+
|
121
|
+
| web |
|
122
|
+
|
123
|
+
| | DELETE | tags/{tag} | tags.destroy | App\Http\Controllers\TagsController@destroy
|
124
|
+
|
125
|
+
| web |
|
126
|
+
|
127
|
+
| | PUT|PATCH | tags/{tag} | tags.update | App\Http\Controllers\TagsController@update
|
128
|
+
|
129
|
+
| web |
|
130
|
+
|
131
|
+
| | GET|HEAD | tags/{tag} | tags.show | App\Http\Controllers\TagsController@show
|
132
|
+
|
133
|
+
| web |
|
134
|
+
|
135
|
+
| | GET|HEAD | tags/{tag}/edit | tags.edit | App\Http\Controllers\TagsController@edit
|
136
|
+
|
137
|
+
| web |
|
138
|
+
|
139
|
+
| | GET|HEAD | users | users.index | App\Http\Controllers\UsersController@index
|
140
|
+
|
141
|
+
| web |
|
142
|
+
|
143
|
+
| | DELETE | users/{user} | users.destroy | App\Http\Controllers\UsersController@destroy
|
144
|
+
|
145
|
+
| web |
|
146
|
+
|
147
|
+
| | PUT|PATCH | users/{user} | users.update | App\Http\Controllers\UsersController@update
|
148
|
+
|
149
|
+
| web |
|
150
|
+
|
151
|
+
| | GET|HEAD | users/{user}/edit | users.edit | App\Http\Controllers\UsersController@edit
|
152
|
+
|
153
|
+
```
|
154
|
+
|
155
|
+
ArticlesController.php
|
156
|
+
|
157
|
+
```
|
158
|
+
|
159
|
+
<?php
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
namespace App\Http\Controllers;
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
use Illuminate\Http\Request;
|
168
|
+
|
169
|
+
use Illuminate\Support\Facades\Auth;
|
170
|
+
|
171
|
+
use App\Article;
|
172
|
+
|
173
|
+
use App\Tag;
|
174
|
+
|
175
|
+
use Redis;
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
class ArticlesController extends Controller
|
182
|
+
|
183
|
+
{
|
184
|
+
|
185
|
+
public function index()
|
186
|
+
|
187
|
+
{
|
188
|
+
|
189
|
+
#新着記事
|
190
|
+
|
191
|
+
$articles = Article::orderBy('created_at', 'desc')->get();
|
192
|
+
|
193
|
+
#日間ランキング
|
194
|
+
|
195
|
+
$ids = REDIS::zrevrangebyscore("articles/daily/" . date('Ymd'), "+inf", 0);
|
196
|
+
|
197
|
+
$articles_ranking_array = [];
|
198
|
+
|
199
|
+
foreach($ids as $id){
|
200
|
+
|
201
|
+
$articles_ranking_array[] = Article::findOrFail($id);
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
#週間ランキング
|
208
|
+
|
209
|
+
$keys = [];
|
210
|
+
|
211
|
+
for($i=0; $i<7; $i++){
|
212
|
+
|
213
|
+
$keys[] = "articles/daily/". date('Ymd', strtotime("-${i} day"));
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
REDIS::zunionstore("articles/weekly/" . date('Ymd'), $keys);
|
218
|
+
|
219
|
+
$week_ids = REDIS::zrevrange("articles/weekly/". date('Ymd'), 0, -1);
|
220
|
+
|
221
|
+
$articles_weekly_ranking_array = [];
|
222
|
+
|
223
|
+
foreach($week_ids as $id){
|
224
|
+
|
225
|
+
$articles_weekly_ranking_array[] = Article::findOrFail($id);
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
#ユーザー専用ランキング
|
230
|
+
|
231
|
+
$user_original_article_array = [];
|
232
|
+
|
233
|
+
if (Auth::check()) {
|
234
|
+
|
235
|
+
foreach($articles_ranking_array as $article){
|
236
|
+
|
237
|
+
foreach($article->tags as $article_tag){
|
238
|
+
|
239
|
+
foreach(Auth::user()->tags as $tag){
|
240
|
+
|
241
|
+
if($tag->id == $article_tag->id){
|
242
|
+
|
243
|
+
$user_original_article_array[] = $article;
|
244
|
+
|
245
|
+
continue 3;
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
$original_article_success = false;
|
260
|
+
|
261
|
+
if(Auth::check()){
|
262
|
+
|
263
|
+
foreach(Auth::user()->tags as $user_tag){
|
264
|
+
|
265
|
+
foreach(Tag::all() as $tag){
|
266
|
+
|
267
|
+
if($user_tag->name == $tag->name){
|
268
|
+
|
269
|
+
$original_article_success = true;
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
return view('articles.index', [
|
282
|
+
|
283
|
+
'articles' => $articles,
|
284
|
+
|
285
|
+
'articles_ranking_array' => $articles_ranking_array,
|
286
|
+
|
287
|
+
'articles_weekly_ranking_array' => $articles_weekly_ranking_array,
|
288
|
+
|
289
|
+
'user_original_article_array' => $user_original_article_array,
|
290
|
+
|
291
|
+
'original_article_success' => $original_article_success,
|
292
|
+
|
293
|
+
]);
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
}
|
298
|
+
|
299
|
+
```
|
300
|
+
|
301
|
+
ArticleControllerのindexアクションのルーティングがうまくいっていません。
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
http://127.0.0.1:8000でも
|
306
|
+
|
307
|
+
http://127.0.0.1:8000/articlesでも404 Not Foundになってしまいます。
|