您好我的项目编辑功能下面有以下代码:
$bankAcc = BankingAccount::find($id)->where('id', $id)->with('userprinciple')->with('banks')->first();
当我dd
$bankAccount
变量时,我得到以下结果:
BankingAccount {#1590 ▼
#fillable: array:8 [▶]
#table: "banking_accounts"
+timestamps: true
#hidden: array:1 [▶]
#connection: "mysql"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:14 [▶]
#original: array:14 [▶]
#changes: []
#casts: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: array:2 [▶]
#touches: []
#visible: []
#guarded: array:1 [▶]
#forceDeleting: false
}
但我只想要对象中属性下的数据。所以我可以在我的刀片中执行此操作:
{{ $bankAcc->userprinciple->principle }}
我一直在尝试各种各样的错误 - 主要是试图显示非对象的属性。那么如何将该数据转换为对象?