質問編集履歴
1
初心者マーク
test
CHANGED
File without changes
|
test
CHANGED
@@ -102,6 +102,88 @@
|
|
102
102
|
|
103
103
|
```
|
104
104
|
|
105
|
+
```migration
|
106
|
+
|
107
|
+
<?php
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
use Illuminate\Database\Migrations\Migration;
|
112
|
+
|
113
|
+
use Illuminate\Database\Schema\Blueprint;
|
114
|
+
|
115
|
+
use Illuminate\Support\Facades\Schema;
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
class CreateFollowsTable extends Migration
|
120
|
+
|
121
|
+
{
|
122
|
+
|
123
|
+
/**
|
124
|
+
|
125
|
+
* Run the migrations.
|
126
|
+
|
127
|
+
*
|
128
|
+
|
129
|
+
* @return void
|
130
|
+
|
131
|
+
*/
|
132
|
+
|
133
|
+
public function up()
|
134
|
+
|
135
|
+
{
|
136
|
+
|
137
|
+
Schema::create('follows', function (Blueprint $table) {
|
138
|
+
|
139
|
+
$table->bigIncrements('id');
|
140
|
+
|
141
|
+
// フォローする側
|
142
|
+
|
143
|
+
$table->bigInteger('following_id')->unsigned();
|
144
|
+
|
145
|
+
// フォローされる側
|
146
|
+
|
147
|
+
$table->bigInteger('followed_id')->unsigned();
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
$table->foreign('following_id')->references('id')->on('users')->onDelete('cascade');
|
152
|
+
|
153
|
+
$table->foreign('followed_id')->references('id')->on('users')->onDelete('cascade');
|
154
|
+
|
155
|
+
$table->timestamps();
|
156
|
+
|
157
|
+
});
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
/**
|
164
|
+
|
165
|
+
* Reverse the migrations.
|
166
|
+
|
167
|
+
*
|
168
|
+
|
169
|
+
* @return void
|
170
|
+
|
171
|
+
*/
|
172
|
+
|
173
|
+
public function down()
|
174
|
+
|
175
|
+
{
|
176
|
+
|
177
|
+
Schema::dropIfExists('follows');
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
```
|
186
|
+
|
105
187
|
試したこと、detatch部分を書き換えましたが無理でした。
|
106
188
|
|
107
189
|
```ここに言語を入力
|