Hallo, ich bin auf ein Problem gestoßen, mein Code lautet:
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')); }
Ich möchte diesen Fehler aus meinem Code beseitigen. Ich stecke hier fest.
$user->plan
evaluates to null. You don't guard against this.optional()
function.User
andPlan
is a belongsTo relationship (User belongsTo Plan), you might be better off just using the foreign key in the user model.