回答編集履歴
2
ヒント追加
answer
CHANGED
@@ -2,4 +2,12 @@
|
|
2
2
|
|
3
3
|
しかし、 `get()` メソッドが返すのは配列ではなく、 `dd()` で見ると表示される通りCollectionインスタンスですので、`empty()` では空かどうかがわからないということです。
|
4
4
|
|
5
|
-
[Collectionについて](https://readouble.com/laravel/5.1/ja/collections.html)
|
5
|
+
[Collectionについて](https://readouble.com/laravel/5.1/ja/collections.html)
|
6
|
+
|
7
|
+
Collectionクラスには `isEmpty()` というメソッドがあるので、それを使うとスマートにかけるかもしれません。
|
8
|
+
|
9
|
+
```php
|
10
|
+
if ($profile->isEmpty()) {
|
11
|
+
//
|
12
|
+
}
|
13
|
+
```
|
1
リンク表示変更
answer
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
確かに`empty()` は空の配列をチェックすることができます。
|
1
|
+
確かに`empty()` は[空の配列をチェックすることができます。](http://php.net/manual/ja/function.empty.php)
|
2
2
|
|
3
|
-
http://php.net/manual/ja/function.empty.php
|
4
|
-
|
5
3
|
しかし、 `get()` メソッドが返すのは配列ではなく、 `dd()` で見ると表示される通りCollectionインスタンスですので、`empty()` では空かどうかがわからないということです。
|
6
4
|
|
7
5
|
[Collectionについて](https://readouble.com/laravel/5.1/ja/collections.html)
|