您好,我遇到一个问题,我的代码是:
if($user->plan->id == 1) {
return view($this->activeTemplate . 'user.autopool', compact('pageTitle', 'commissions', 'deposit', 'transactions', 'commission', 'withdraw', 'transaction', 'username', 'balance', 'user', 'plans'));
} else {
return view($this->activeTemplate . 'user.nopool', compact('pageTitle', 'user'));
}
我想从我的代码中消除这个错误。我被困在这里了。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
$user->planevaluates to null. You don't guard against this.optional()function.UserandPlanis a belongsTo relationship (User belongsTo Plan), you might be better off just using the foreign key in the user model.