質問編集履歴

4

web.phpの全文

2020/04/11 11:58

投稿

Himajin_akisyou
Himajin_akisyou

スコア12

test CHANGED
File without changes
test CHANGED
@@ -36,12 +36,84 @@
36
36
 
37
37
  //web.php
38
38
 
39
+ <?php
40
+
41
+
42
+
43
+ use Illuminate\Support\Facades\Route;
44
+
45
+
46
+
47
+ /*
48
+
49
+ |--------------------------------------------------------------------------
50
+
51
+ | Web Routes
52
+
53
+ |--------------------------------------------------------------------------
54
+
55
+ |
56
+
57
+ | Here is where you can register web routes for your application. These
58
+
59
+ | routes are loaded by the RouteServiceProvider within a group which
60
+
61
+ | contains the "web" middleware group. Now create something great!
62
+
63
+ |
64
+
65
+ */
66
+
67
+
68
+
69
+ Route::get('/', function () {
70
+
71
+ return view('welcome');
72
+
73
+ });
74
+
75
+
76
+
77
+ //ログイン確認不要
78
+
79
+ Route::get('/mypage/{post_id}', 'PostController@edit')->name('edit_post');
80
+
81
+ Route::post('/mypage/{post_id}', 'PostController@editing');
82
+
83
+
84
+
85
+ Route::get('/mypage/{post_id}/{comment_id}')->name('comment_delete');
86
+
87
+
88
+
89
+
90
+
91
+ //ログイン確認必要
92
+
93
+ //
94
+
95
+ Route::get('/mypage', 'MypageController@index')->name('mypage');
96
+
97
+ //新規投稿
98
+
99
+ //ここのルートを実行しました
100
+
39
101
  Route::get('/mypage/post', function(){
40
102
 
41
103
  return view('create_post');
42
104
 
43
105
  })->name('create_post');
44
106
 
107
+
108
+
109
+
110
+
111
+ Auth::routes();
112
+
113
+ Route::get('/home', 'HomeController@index')->name('home');
114
+
115
+
116
+
45
117
  ```
46
118
 
47
119
 

3

追記の再修正

2020/04/11 11:58

投稿

Himajin_akisyou
Himajin_akisyou

スコア12

test CHANGED
File without changes
test CHANGED
@@ -168,50 +168,16 @@
168
168
 
169
169
  ターミナルでphp artisan route:list --name=create_postを実行した結果です。
170
170
 
171
+ ```
172
+
171
- エラーが出ましたが、そのままコピーして記載しています。
173
+ +--------+----------+-------------+-------------+---------+------------+
174
+
175
+ | Domain | Method | URI | Name | Action | Middleware |
176
+
177
+ +--------+----------+-------------+-------------+---------+------------+
178
+
179
+ | | GET|HEAD | mypage/post | create_post | Closure | web |
180
+
181
+ +--------+----------+-------------+-------------+---------+------------+
172
182
 
173
183
  ```
174
-
175
- Illuminate\Contracts\Container\BindingResolutionException
176
-
177
-
178
-
179
- Target class [App\Http\Controllers\CommentController] does not exist.
180
-
181
-
182
-
183
- at vendor/laravel/framework/src/Illuminate/Container/Container.php:809
184
-
185
- 805|
186
-
187
- 806| try {
188
-
189
- 807| $reflector = new ReflectionClass($concrete);
190
-
191
- 808| } catch (ReflectionException $e) {
192
-
193
- > 809| throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
194
-
195
- 810| }
196
-
197
- 811|
198
-
199
- 812| // If the type is not instantiable, the developer is attempting to resolve
200
-
201
- 813| // an abstract type such as an Interface or Abstract Class and there is
202
-
203
-
204
-
205
- 1 [internal]:0
206
-
207
- Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}(Object(Illuminate\Routing\Route))
208
-
209
-
210
-
211
- +12 vendor frames
212
-
213
- 14 [internal]:0
214
-
215
- Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}(Object(Illuminate\Routing\Route))
216
-
217
- ```

2

Post.phpの追記

2020/04/11 07:20

投稿

Himajin_akisyou
Himajin_akisyou

スコア12

test CHANGED
File without changes
test CHANGED
@@ -122,6 +122,48 @@
122
122
 
123
123
 
124
124
 
125
+ ```php
126
+
127
+ //Post.php
128
+
129
+ <?php
130
+
131
+
132
+
133
+ namespace App;
134
+
135
+
136
+
137
+ use Illuminate\Database\Eloquent\Model;
138
+
139
+
140
+
141
+ class Post extends Model
142
+
143
+ {
144
+
145
+ //
146
+
147
+ public function comments(){
148
+
149
+ return $this->hasMany('App\Comment');
150
+
151
+ }
152
+
153
+
154
+
155
+ public function user(){
156
+
157
+ return $this->belongsTo('App\User');
158
+
159
+ }
160
+
161
+ }
162
+
163
+ ```
164
+
165
+
166
+
125
167
  ###追記
126
168
 
127
169
  ターミナルでphp artisan route:list --name=create_postを実行した結果です。

1

php artisan route:list --name=create_postを実行しました

2020/04/11 07:10

投稿

Himajin_akisyou
Himajin_akisyou

スコア12

test CHANGED
File without changes
test CHANGED
@@ -119,3 +119,57 @@
119
119
 
120
120
 
121
121
  ```
122
+
123
+
124
+
125
+ ###追記
126
+
127
+ ターミナルでphp artisan route:list --name=create_postを実行した結果です。
128
+
129
+ エラーが出ましたが、そのままコピーして記載しています。
130
+
131
+ ```
132
+
133
+ Illuminate\Contracts\Container\BindingResolutionException
134
+
135
+
136
+
137
+ Target class [App\Http\Controllers\CommentController] does not exist.
138
+
139
+
140
+
141
+ at vendor/laravel/framework/src/Illuminate/Container/Container.php:809
142
+
143
+ 805|
144
+
145
+ 806| try {
146
+
147
+ 807| $reflector = new ReflectionClass($concrete);
148
+
149
+ 808| } catch (ReflectionException $e) {
150
+
151
+ > 809| throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
152
+
153
+ 810| }
154
+
155
+ 811|
156
+
157
+ 812| // If the type is not instantiable, the developer is attempting to resolve
158
+
159
+ 813| // an abstract type such as an Interface or Abstract Class and there is
160
+
161
+
162
+
163
+ 1 [internal]:0
164
+
165
+ Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}(Object(Illuminate\Routing\Route))
166
+
167
+
168
+
169
+ +12 vendor frames
170
+
171
+ 14 [internal]:0
172
+
173
+ Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}(Object(Illuminate\Routing\Route))
174
+
175
+ ```