【发布时间】:2020-06-26 15:47:43
【问题描述】:
在其中一个控制器功能中
$readings = Reading::orderBy('reading_date_time', 'DESC')->get();
dd($readings);
这给了
Illuminate\Database\Eloquent\Collection {#1883
#items: array:160 [
0 => App\Reading {#1722
#fillable: array:6 [ …6]
#connection: "mysql"
#table: "readings"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:8 [ …8]
#original: array:8 [ …8]
#changes: []
#casts: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#hidden: []
#visible: []
#guarded: array:1 [ …1]
}...
如何访问读数表的实际值。并将它们用于 array_column() 等操作。
【问题讨论】:
-
stackoverflow.com/questions/62213847/…如果想访问#staring variables的值,可以检查这个
标签: arrays laravel collections eloquent model