到目前为止,我将关系对象提取为数组,然后执行以下操作:
App\Model::find($id)
Run Code Online (Sandbox Code Playgroud)
但是有没有办法做一些事情:
Auth::user()->group()->members()
Run Code Online (Sandbox Code Playgroud)
它可以工作,Auth::user()->group但没有进一步的链接.如果你做了什么,请帮忙.或者我只是新手.
我UITabBarController在应用程序中使用“自定义”来检查选定的索引。当我选择时,我会触发此方法selectedIndex:
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
// print(self.selectedIndex)
switch self.selectedIndex {
case 1:
print("should load feed " + String(self.selectedIndex))
(self.viewControllers![1] as? PageViewController)?.downloadNews()
case 2:
print("should load saved" + String(self.selectedIndex))
(self.viewControllers![2] as? SavedController)?.loadData()
default:
return
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我单击新的标签栏项目时,会得到旧的选定索引。我知道这很容易。有没有办法在这种方法中取出正确的索引?