質問編集履歴

3

修正しました。

2022/06/05 01:29

投稿

free_teku
free_teku

スコア103

test CHANGED
File without changes
test CHANGED
@@ -19,6 +19,8 @@
19
19
  エラー:A table was not found: You might have forgotten to run your migrations. You can run your migrations using `php artisan migrate`.
20
20
  ```
21
21
  ###コード
22
+
23
+ ```
22
24
  Model
23
25
  <?php
24
26
 
@@ -33,7 +35,10 @@
33
35
  use HasFactory;
34
36
  }
35
37
 
38
+ ```
36
39
 
40
+
41
+ ```
37
42
  migration
38
43
  <?php
39
44
 
@@ -69,6 +74,8 @@
69
74
  }
70
75
  }
71
76
 
77
+ ```
78
+
72
79
 
73
80
  ### 試したこと・考えたこと
74
81
  <考えたこと>

2

追記しました。

2022/06/04 23:42

投稿

free_teku
free_teku

スコア103

test CHANGED
File without changes
test CHANGED
@@ -18,6 +18,56 @@
18
18
  ```
19
19
  エラー:A table was not found: You might have forgotten to run your migrations. You can run your migrations using `php artisan migrate`.
20
20
  ```
21
+ ###コード
22
+ Model
23
+ <?php
24
+
25
+ namespace App\Models;
26
+
27
+ use Illuminate\Database\Eloquent\Factories\HasFactory;
28
+ use Illuminate\Database\Eloquent\Model;
29
+
30
+ class UserInformation extends Model
31
+ {
32
+ protected $table = 'user_information';
33
+ use HasFactory;
34
+ }
35
+
36
+
37
+ migration
38
+ <?php
39
+
40
+ use Illuminate\Database\Migrations\Migration;
41
+ use Illuminate\Database\Schema\Blueprint;
42
+ use Illuminate\Support\Facades\Schema;
43
+
44
+ class CreateUserInformationTable extends Migration
45
+ {
46
+ /**
47
+ * Run the migrations.
48
+ *
49
+ * @return void
50
+ */
51
+ public function up()
52
+ {
53
+ Schema::table('user_information', function (Blueprint $table) {
54
+ $table->unsignedBigInteger('user_id');
55
+ $table->unsignedInteger('height', 5,1);
56
+ $table->unsignedDecimal('weight',5,1);
57
+ $table->unsignedTinyInteger('age', 100);
58
+ });
59
+ }
60
+
61
+ /**
62
+ * Reverse the migrations.
63
+ *
64
+ * @return void
65
+ */
66
+ public function down()
67
+ {
68
+ Schema::dropIfExists('user_information');
69
+ }
70
+ }
21
71
 
22
72
 
23
73
  ### 試したこと・考えたこと

1

修正しました

2022/06/04 15:46

投稿

free_teku
free_teku

スコア103

test CHANGED
File without changes
test CHANGED
@@ -1,7 +1,7 @@
1
1
  ### 前提・実現したいこと
2
2
  Laravel ver 8を使っています。
3
3
 
4
- 自身で開発をしていて、上kのように、テーブル名を informationで終わるテーブル名を書いています。
4
+ 自身で開発をしていて、上のように、テーブル名を informationで終わるテーブル名を書いています。
5
5
 
6
6
  しかし、下記のようにエラーが出ました。
7
7