質問編集履歴
1
UserClass
test
CHANGED
File without changes
|
test
CHANGED
@@ -281,3 +281,33 @@
|
|
281
281
|
{}と[]の違いもいまいち理解できてないのですが、
|
282
282
|
|
283
283
|
foreachと$friends[0]とやっている処理は同じではないのでしょうか?
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
```PHP
|
288
|
+
|
289
|
+
//Userクラスになります
|
290
|
+
|
291
|
+
class User extends Model
|
292
|
+
|
293
|
+
{
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
public function friends()
|
298
|
+
|
299
|
+
{
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
$friend_ids = $this -> hasMany('App\Friend')->select(['friend_id']);
|
304
|
+
|
305
|
+
return $friend_ids;
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
```
|