質問編集履歴

7

php artisan db:seed -v追加

2019/08/10 09:37

投稿

Ms.yy
Ms.yy

スコア83

test CHANGED
File without changes
test CHANGED
@@ -333,3 +333,139 @@
333
333
 
334
334
 
335
335
  ```
336
+
337
+
338
+
339
+ ###php artisan db:seed -v
340
+
341
+ ```ここに言語を入力
342
+
343
+ vagrant@homestead:~/code/laravel$ php artisan db:seed -v
344
+
345
+ Seeding: PostsTableSeeder
346
+
347
+
348
+
349
+ InvalidArgumentException : Unable to locate factory with name [default] [App\Post].
350
+
351
+
352
+
353
+ at /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:269
354
+
355
+ 265| */
356
+
357
+ 266| protected function getRawAttributes(array $attributes = [])
358
+
359
+ 267| {
360
+
361
+ 268| if (! isset($this->definitions[$this->class][$this->name])) {
362
+
363
+ > 269| throw new InvalidArgumentException("Unable to locate factory with name [{$this->name}] [{$this->class}].");
364
+
365
+ 270| }
366
+
367
+ 271|
368
+
369
+ 272| $definition = call_user_func(
370
+
371
+ 273| $this->definitions[$this->class][$this->name],
372
+
373
+
374
+
375
+ Exception trace:
376
+
377
+
378
+
379
+ 1 Illuminate\Database\Eloquent\FactoryBuilder::getRawAttributes([])
380
+
381
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:292
382
+
383
+
384
+
385
+ 2 Illuminate\Database\Eloquent\FactoryBuilder::Illuminate\Database\Eloquent\{closure}()
386
+
387
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php:116
388
+
389
+
390
+
391
+ 3 Illuminate\Database\Eloquent\Model::unguarded(Object(Closure))
392
+
393
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:300
394
+
395
+
396
+
397
+ 4 Illuminate\Database\Eloquent\FactoryBuilder::makeInstance([])
398
+
399
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:229
400
+
401
+
402
+
403
+ 5 Illuminate\Database\Eloquent\FactoryBuilder::Illuminate\Database\Eloquent\{closure}()
404
+
405
+ [internal]:0
406
+
407
+
408
+
409
+ 6 array_map(Object(Closure))
410
+
411
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:230
412
+
413
+
414
+
415
+ 7 Illuminate\Database\Eloquent\FactoryBuilder::make([])
416
+
417
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:178
418
+
419
+
420
+
421
+ 8 Illuminate\Database\Eloquent\FactoryBuilder::create()
422
+
423
+ /home/vagrant/code/laravel/database/seeds/PostsTableSeeder.php:17
424
+
425
+
426
+
427
+ 9 PostsTableSeeder::run()
428
+
429
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
430
+
431
+
432
+
433
+ 10 call_user_func_array([])
434
+
435
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
436
+
437
+
438
+
439
+ 11 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
440
+
441
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
442
+
443
+
444
+
445
+ 12 Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))
446
+
447
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
448
+
449
+
450
+
451
+ 13 Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])
452
+
453
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php:576
454
+
455
+
456
+
457
+ 14 Illuminate\Container\Container::call()
458
+
459
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Database/Seeder.php:122
460
+
461
+
462
+
463
+ 15 Illuminate\Database\Seeder::__invoke()
464
+
465
+ /home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Database/Seeder.php:42
466
+
467
+
468
+
469
+
470
+
471
+ ```

6

環境にhomestead記載

2019/08/10 09:37

投稿

Ms.yy
Ms.yy

スコア83

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  [環境]
14
14
 
15
-
15
+ homestead上で実行
16
16
 
17
17
  PHP 7.3.7
18
18
 

5

pwd追記

2019/08/10 09:31

投稿

Ms.yy
Ms.yy

スコア83

test CHANGED
File without changes
test CHANGED
@@ -268,9 +268,13 @@
268
268
 
269
269
 
270
270
 
271
+
272
+
273
+
274
+
271
- ```
275
+ ```
276
+
272
-
277
+ ### **__ ここから回答後の追記__**
273
-
274
278
 
275
279
 
276
280
 
@@ -315,3 +319,17 @@
315
319
  }
316
320
 
317
321
  ```
322
+
323
+
324
+
325
+ ###ディレクトリ構造
326
+
327
+ ```ここに言語を入力
328
+
329
+ vagrant@homestead:~/code/laravel$ pwd
330
+
331
+ /home/vagrant/code/laravel
332
+
333
+
334
+
335
+ ```

4

追記

2019/08/10 09:28

投稿

Ms.yy
Ms.yy

スコア83

test CHANGED
File without changes
test CHANGED
@@ -269,3 +269,49 @@
269
269
 
270
270
 
271
271
  ```
272
+
273
+
274
+
275
+
276
+
277
+ ### app/Post.php
278
+
279
+ ```ここに言語を入力
280
+
281
+ <?php
282
+
283
+
284
+
285
+ namespace App;
286
+
287
+
288
+
289
+ use Illuminate\Database\Eloquent\Model;
290
+
291
+
292
+
293
+ class Post extends Model
294
+
295
+ {
296
+
297
+ protected $fillable = [
298
+
299
+ 'title',
300
+
301
+ 'body',
302
+
303
+ ];
304
+
305
+
306
+
307
+ public function comments()
308
+
309
+ {
310
+
311
+ return $this->hasMany('App\Comment');
312
+
313
+ }
314
+
315
+ }
316
+
317
+ ```

3

スペルミス

2019/08/10 07:04

投稿

Ms.yy
Ms.yy

スコア83

test CHANGED
@@ -1 +1 @@
1
- Laraelのartisan db:seed実行時にエラー(Unable to locate factory with name [default] [App\Post].)
1
+ Laravelのartisan db:seed実行時にエラー(Unable to locate factory with name [default] [App\Post].)
test CHANGED
@@ -146,7 +146,7 @@
146
146
 
147
147
 
148
148
 
149
- ### psotTableSeeder
149
+ ### postTableSeeder
150
150
 
151
151
  ```ここに言語を入力
152
152
 
@@ -202,7 +202,7 @@
202
202
 
203
203
 
204
204
 
205
- ### userfactry.php
205
+ ### userfactory.php
206
206
 
207
207
  ```ここに言語を入力
208
208
 
@@ -242,7 +242,7 @@
242
242
 
243
243
 
244
244
 
245
- ### postfactry.php
245
+ ### postfactory.php
246
246
 
247
247
  ```ここに言語を入力
248
248
 

2

参考サイト追記

2019/08/10 03:52

投稿

Ms.yy
Ms.yy

スコア83

test CHANGED
File without changes
test CHANGED
@@ -6,6 +6,10 @@
6
6
 
7
7
 
8
8
 
9
+ [参考にしているサイト](https://blog.hiroyuki90.com/articles/laravel-bbs/#i-5)はこちらで、コードはそのままコピぺしております。
10
+
11
+
12
+
9
13
  [環境]
10
14
 
11
15
 

1

編集追記

2019/08/10 01:51

投稿

Ms.yy
Ms.yy

スコア83

test CHANGED
@@ -1 +1 @@
1
- Laraelのphp artisan db:seed実行時にエラー(Unable to locate factory with name [default] [App\Post].)
1
+ Laraelのartisan db:seed実行時にエラー(Unable to locate factory with name [default] [App\Post].)
test CHANGED
@@ -24,7 +24,9 @@
24
24
 
25
25
  [試したこと]
26
26
 
27
+ 同じエラーである下記のサイトを参考にしました。
28
+
27
- 同じエラーであるこちらの内容のApp\Postをuserfactry.phpのApp\Commentの部分に書き換えましたが変わらず。
29
+ 具体的にエラー内容であるApp\Postをuserfactry.phpのApp\Commentの部分に書き換えましたが変わらず。
28
30
 
29
31
 
30
32