我想從練習表訪問名稱屬性,但我得到的集合。我的代碼看起來像。如何訪問集合中的特定屬性?
$practice = Practice::withTrashed()->where('id',$appointment->practice_id)->get();
dd($practice);
和結果如下
Collection {#697
#items: array:1 [
0 => Practice {#698
#dates: array:1 [
0 => "deleted_at"
]
#fillable: array:2 [
0 => "name"
1 => "email"
]
#connection: null
#table: null
#primaryKey: "id"
#keyType: "int"
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:7 [
"id" => 42
"name" => "DJ and Charlie Eye Associates"
"email" => "[email protected]"
"created_at" => "0000-00-00 00:00:00"
"updated_at" => "2017-01-13 06:29:14"
"liferay_id" => 57238
"deleted_at" => "2017-01-13 06:29:14"
]
#original: array:7 [
"id" => 42
"name" => "DJ and Charlie Eye Associates"
"email" => "[email protected]"
"created_at" => "0000-00-00 00:00:00"
"updated_at" => "2017-01-13 06:29:14"
"liferay_id" => 57238
"deleted_at" => "2017-01-13 06:29:14"
]
#relations: []
#hidden: []
#visible: []
#appends: []
#guarded: array:1 [
0 => "*"
]
#dateFormat: null
#casts: []
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
+wasRecentlyCreated: false
#forceDeleting: false
}
]
}
有沒有辦法做的,所以我可以得到名爲「DJ和查理眼科協會」。我和Thrashed方法一起使用,因爲這個條目在練習表中被軟刪除。
它應該工作.. –