質問編集履歴
3
ソースコードを修正しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,14 +11,14 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
```該当エラー
|
14
|
-
Class "
|
14
|
+
Class "app\Models\Task" not found
|
15
15
|
|
16
16
|
at database/seeders/TasksTableSeeder.php:18
|
17
17
|
14▕ */
|
18
18
|
15▕ public function run()
|
19
19
|
16▕ {
|
20
20
|
17▕ for ($i = 1; $i <= 10; $i++){
|
21
|
-
➜ 18▕
|
21
|
+
➜ 18▕ Task::create([
|
22
22
|
19▕ 'title' => 'title' . $i,
|
23
23
|
20▕ 'content'=> 'content' . $i,
|
24
24
|
21▕ 'person_in_charge'=>'person_in_charge' . $i,
|
@@ -54,7 +54,7 @@
|
|
54
54
|
|
55
55
|
namespace Database\Seeders;
|
56
56
|
|
57
|
-
use
|
57
|
+
use app\Models\Task;
|
58
58
|
use Illuminate\Database\Seeder;
|
59
59
|
|
60
60
|
class TasksTableSeeder extends Seeder
|
@@ -83,7 +83,7 @@
|
|
83
83
|
|
84
84
|
namespace Database\Seeders;
|
85
85
|
|
86
|
-
use
|
86
|
+
use app\Models\Task;
|
87
87
|
use Illuminate\Database\Seeder;
|
88
88
|
use Illuminate\Support\Facades\DB;
|
89
89
|
|
@@ -154,7 +154,7 @@
|
|
154
154
|
```Task.php
|
155
155
|
<?php
|
156
156
|
|
157
|
-
namespace
|
157
|
+
namespace app\Models\Task;
|
158
158
|
|
159
159
|
|
160
160
|
use Illuminate\Database\Eloquent\Model;
|
2
エラー文を修正しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,26 +11,18 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
```該当エラー
|
14
|
-
Class "App\Task" not found
|
14
|
+
Class "Database\Seeders\App\Models\Task" not found
|
15
15
|
|
16
16
|
at database/seeders/TasksTableSeeder.php:18
|
17
17
|
14▕ */
|
18
18
|
15▕ public function run()
|
19
19
|
16▕ {
|
20
20
|
17▕ for ($i = 1; $i <= 10; $i++){
|
21
|
-
➜ 18▕ Task::create([
|
21
|
+
➜ 18▕ App\Models\Task::create([
|
22
|
-
19▕ 'title' => 'title'
|
22
|
+
19▕ 'title' => 'title' . $i,
|
23
|
-
20▕ 'content'=> 'content'
|
23
|
+
20▕ 'content'=> 'content' . $i,
|
24
|
-
21▕ 'person_in_charge'=>'person_in_charge'
|
24
|
+
21▕ 'person_in_charge'=>'person_in_charge' . $i,
|
25
25
|
22▕ ]);
|
26
|
-
|
27
|
-
+7 vendor frames
|
28
|
-
8 database/seeders/DatabaseSeeder.php:19
|
29
|
-
Illuminate\Database\Seeder::call()
|
30
|
-
|
31
|
-
+35 vendor frames
|
32
|
-
44 artisan:37
|
33
|
-
Illuminate\Foundation\Console\Kernel::handle()
|
34
26
|
```
|
35
27
|
|
36
28
|
https://qiita.com/minato-naka/items/0e709cb0e6628c82c1c5
|
1
ソースコードを大幅に変更しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -62,7 +62,7 @@
|
|
62
62
|
|
63
63
|
namespace Database\Seeders;
|
64
64
|
|
65
|
-
use App\Task;
|
65
|
+
use App\Models\Task;
|
66
66
|
use Illuminate\Database\Seeder;
|
67
67
|
|
68
68
|
class TasksTableSeeder extends Seeder
|
@@ -76,20 +76,22 @@
|
|
76
76
|
{
|
77
77
|
for ($i = 1; $i <= 10; $i++){
|
78
78
|
Task::create([
|
79
|
-
'title' => 'title'
|
79
|
+
'title' => 'title' . $i,
|
80
|
-
'content'=> 'content'
|
80
|
+
'content'=> 'content' . $i,
|
81
|
-
'person_in_charge'=>'person_in_charge'
|
81
|
+
'person_in_charge'=>'person_in_charge' . $i,
|
82
82
|
]);
|
83
83
|
}
|
84
84
|
}
|
85
85
|
}
|
86
86
|
|
87
|
+
|
87
88
|
```
|
88
89
|
```DatabaseSeeder.php
|
89
90
|
<?php
|
90
91
|
|
91
92
|
namespace Database\Seeders;
|
92
93
|
|
94
|
+
use App\Models\Task;
|
93
95
|
use Illuminate\Database\Seeder;
|
94
96
|
use Illuminate\Support\Facades\DB;
|
95
97
|
|
@@ -118,6 +120,7 @@
|
|
118
120
|
|
119
121
|
class CreateTasksTable extends Migration
|
120
122
|
{
|
123
|
+
protected $connection = 'mysql';
|
121
124
|
/**
|
122
125
|
* Run the migrations.
|
123
126
|
*
|
@@ -125,13 +128,22 @@
|
|
125
128
|
*/
|
126
129
|
public function up()
|
127
130
|
{
|
128
|
-
Schema::create('tasks', function (Blueprint $table) {
|
131
|
+
Schema::connection('mysql')->create('tasks', function (Blueprint $table) {
|
129
132
|
$table->bigIncrements('id');
|
130
133
|
$table->string('title', 100);
|
131
134
|
$table->string('content', 100);
|
132
135
|
$table->string('person_in_charge', 100);
|
133
136
|
$table->timestamps();
|
134
137
|
});
|
138
|
+
|
139
|
+
Schema::create('tasks', function(Blueprint $table){
|
140
|
+
$table->engine = 'InnoDB';
|
141
|
+
});
|
142
|
+
|
143
|
+
Schema::create('tasks', function(Blueprint $table){
|
144
|
+
$table->charset = 'utf8mb4';
|
145
|
+
$table->collation = 'utf8mb4_unicode_ci';
|
146
|
+
});
|
135
147
|
}
|
136
148
|
|
137
149
|
/**
|
@@ -150,7 +162,7 @@
|
|
150
162
|
```Task.php
|
151
163
|
<?php
|
152
164
|
|
153
|
-
namespace App;
|
165
|
+
namespace App\Models\Task;
|
154
166
|
|
155
167
|
|
156
168
|
use Illuminate\Database\Eloquent\Model;
|
@@ -158,6 +170,7 @@
|
|
158
170
|
|
159
171
|
class Task extends Model
|
160
172
|
{
|
173
|
+
protected $connection ='mysql';
|
161
174
|
protected $fillable = [
|
162
175
|
'title',
|
163
176
|
'content',
|