未获得非对象的属性

问题描述 投票:0回答:1

我遇到以下错误:

b836960d8afb261ac0cd337b0ac052bd22c615b4.php第2行中的ErrorException:试图获取非对象的属性(查看:C:\ wamp64 \ www \ peepbox \ resources \ views \ timeline \ partials \ friendtofriendstatusblock.blade.php)(视图:C:\ wamp64 \ www \ peepbox \ resources \ views \ timeline \ partials \ friendtofriendstatusblock.blade.php

我的控制器:

class HomeController extends Controller {

    public function index(Request $request) {

        if(Auth::check()) {

            $statuses = Status::NotReply()->NotFriendPostUserProfile()->where(function($query) {
                return $query->where('user_id', Auth::user()->id)
                            ->orWhereIn('user_id', Auth::user()->friends()->lists('id'));
            })->orderBy('created_at', 'desc')->paginate(4);

            $friendPosts = Status::NotReply()->FriendPostUserProfile()->where(function($query) {
                return $query->where('user_id', Auth::user()->id)
                            ->orWhereIn('user_id', Auth::user()->friends()->lists('id'));
            })->orderBy('created_at', 'desc')->paginate(4);


            if($request->ajax()) {

                return view('timeline.ajax.index')->with('statuses', $statuses)->with('friendPosts', $friendPosts)->render();
            }

            return view('timeline.index')->with('statuses', $statuses)->with('friendPosts', $friendPosts);
        }

        return view('home');
    }
}
php laravel
1个回答
0
投票

有效。

$statuses = Status::NotReply()->NotFriendPostUserProfile()->where(function($query) {
                return $query->where('user_id', Auth::user()->id)
                            ->orWhereIn('user_id', Auth::user()->friends()->lists('id'));
            });

            $friendPosts = Status::NotReply()->FriendPostUserProfile()->where(function($query) {
                return $query->where('user_id', Auth::user()->id)
                            ->orWhereIn('user_id', Auth::user()->friends()->lists('id'));
            });
© www.soinside.com 2019 - 2024. All rights reserved.