尝试获取非对象的属性“名称”(视图:C:\ xampp \ htdocs \ restaurant-finder-master \ resources \ views \ layouts \ app.blade.php)

时间:2019-07-03 15:58:33

标签: php

我遇到此问题,我正在尝试向auth注册,但我仍然看到此错误 尝试获取非对象的属性“名称”

let databaseRef = Database.database().reference(withPath: "developer")
    databaseRef.observe(.value) { (snapshot) in
        print(snapshot.childrenCount) //3
        if let snapshot = snapshot.children.allObjects as? [DataSnapshot] {
            for snap in snapshot {

                if let postDict = snap.value as? Dictionary<String, AnyObject> {
                    if let name = postDict["name"] {
                        print(name)
                    }
                    //print(postDict.keys) // name, email, id, image
                } else {
                    print("Failed to convert.")
                }
            }
        }
    }
  

试图获取非对象的属性“名称”

1 个答案:

答案 0 :(得分:0)

您必须先访问auth,然后才能进入主页,主页(仪表板)需要经过身份验证的用户,但您未经过身份验证(猜测用户)就可以访问

您可以像这样从route.php检查auth:

Route::get('/', 'ExampleController@index')->middleware('auth');

或者您可以像这样检查控制器构造函数:auth()->check()

或者您可以在视图中使用:@guest @else @endguest