arrays - 在 Laravel 中打印出集合的值

标签 arrays debugging laravel-5 collections

在我的 Controller 中我有

$all = \App\Product::where('campaign_id', $product->campaign_id)->get();

当我在模板中 DD 时

{{ dd($all)}}

我得到一个集合对象

Collection {#340 ▼
  #items: array:1 [▼
    0 => Product {#341 ▼
      #connection: "mysql"
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:10 [▶]
      #original: array:10 [▶]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #fillable: []
      #guarded: array:1 [▶]
    }
  ]
}

如何查看返回的基本数组?

最佳答案

我知道这个问题很老,但不敢相信没有答案。

需要将eloquent模型转成数组,才能展示

{{ dd($all->toArray()) }} 

更多信息在这里:https://laravel.com/docs/5.6/eloquent-serialization

关于arrays - 在 Laravel 中打印出集合的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45099613/

相关文章:

javascript - JavaScript 中有字典实现吗?

debugging - 避免 R 中的浏览器调用

php - Laravel 5 无法将变量传递给所有 View

mysql - LARAVEL 5.5 外键约束的格式不正确'

c# - 我应该在 #if (DEBUG) 中包装对 Debugger.Log() 的调用吗?

php - MySQL 中的双引号 (Laravel Seeder)

Java 2D 数组 : Multiplication Table

java - 如何在数组中保存运行计数?

python - 如何对 numpy 数组中的多个变量求和?

asp.net - "unable to start debugging on the web server"MSVSMON.EXE 无法启动。 VS2010 错误