回答編集履歴

3

修正

2019/10/24 05:33

投稿

退会済みユーザー
test CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  $companies = Company::all()->map(function ($item, $key){
26
26
 
27
- return $item->pop('stuff_name');
27
+ return $item->pull('stuff_name');
28
28
 
29
29
  });
30
30
 
@@ -36,4 +36,4 @@
36
36
 
37
37
  [https://readouble.com/laravel/6.0/ja/collections.html#method-map](https://readouble.com/laravel/6.0/ja/collections.html#method-map)
38
38
 
39
- [https://readouble.com/laravel/6.0/ja/collections.html#method-pop](https://readouble.com/laravel/6.0/ja/collections.html#method-pop)
39
+ [https://readouble.com/laravel/6.0/ja/collections.html#method-pull](https://readouble.com/laravel/6.0/ja/collections.html#method-pull)

2

修正

2019/10/24 05:33

投稿

退会済みユーザー
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  ```php
24
24
 
25
- $companies = Company::query()->get()->map(function ($item, $key){
25
+ $companies = Company::all()->map(function ($item, $key){
26
26
 
27
27
  return $item->pop('stuff_name');
28
28
 

1

追記

2019/10/24 05:31

投稿

退会済みユーザー
test CHANGED
@@ -5,3 +5,35 @@
5
5
  return $companies;
6
6
 
7
7
  ```
8
+
9
+
10
+
11
+ ---
12
+
13
+
14
+
15
+ > 「stuff_name以外」は指示できるのでしょうか?
16
+
17
+
18
+
19
+ 動作未検証ですが。
20
+
21
+
22
+
23
+ ```php
24
+
25
+ $companies = Company::query()->get()->map(function ($item, $key){
26
+
27
+ return $item->pop('stuff_name');
28
+
29
+ });
30
+
31
+ return $companies;
32
+
33
+ ```
34
+
35
+
36
+
37
+ [https://readouble.com/laravel/6.0/ja/collections.html#method-map](https://readouble.com/laravel/6.0/ja/collections.html#method-map)
38
+
39
+ [https://readouble.com/laravel/6.0/ja/collections.html#method-pop](https://readouble.com/laravel/6.0/ja/collections.html#method-pop)