Laravel如何检查对象为空

时间:2019-01-15 03:00:19

标签: laravel object

我可以检查对象为空吗?

我正在尝试

dd($result,empty($result->Monday),is_null($result->Monday));

但是返回false

这是我的对象

{#1041 ▼
  +"Monday": {#1038}
  +"Tuesday": {#1040 ▶}
  +"Wednesday": {#1058 ▶}
  +"Thursday": {#1060 ▶}
  +"Friday": {#1062 ▶}
  +"Saturday": {#1065 ▶}
  +"Sunday": {#1067 ▶}
}

1 个答案:

答案 0 :(得分:0)

在将对象发送到视图之前,我给了值null。然后检查刀片服务器上的null

{#1041 ▼
  +"Monday": Null
  +"Tuesday": {#1040 ▶}
  +"Wednesday": {#1058 ▶}
  +"Thursday": {#1060 ▶}
  +"Friday": {#1062 ▶}
  +"Saturday": {#1065 ▶}
  +"Sunday": {#1067 ▶}
}