0

i want to update user with below code but problem is that its update balance perfectly but also giving error in LOgs. and i am unable to figureout issue also tried

findorfail()

production.ERROR: Creating default object from empty value {"exception":"[object] (ErrorException(code: 0):
public function updateBalance(){
    $gnl = General::first();
    $deposit = Deposit::where('status', 1)->get();
    foreach($deposit as $de){
                $pack = Package::Where('id',$de->plan)->first();
                $log = Deposit::Where('id',$de->id)->first();

       $percent = $log->amount * $pack->percent/100;
       $repercent = $percent/1440 ; 
      $tup = Track::where('account_id',$de->account_id)->first();
        $tup->balance +=$repercent; //here getting error line
                $tup->save();
    }
    }
waqar
  • 75
  • 1
  • 14
  • 1
    Possible duplicate of [Creating default object from empty value in PHP?](https://stackoverflow.com/questions/8900701/creating-default-object-from-empty-value-in-php) – Jerodev Nov 27 '19 at 13:01
  • If the error is where you are indicating, that would seem to indicate that `Track::where()` is returning no results. You should perhaps check that `$tup` has been created as the expected object before performing the following two lines. – Patrick Q Nov 27 '19 at 13:07
  • @PatrickQ but its updatin the balance of user that is mentioned in query as well – waqar Nov 27 '19 at 13:12
  • Is this your _exact_ code, copy/pasted with no changes (except for the comment indicating the error line)? – Patrick Q Nov 27 '19 at 13:16
  • Your error message appears to be trimmed. Could you please provide the full error message text? – Patrick Q Nov 27 '19 at 13:17
  • @PatrickQ [2019-11-27 17:55:36] production.ERROR: Creating default object from empty value {"exception":"[object] (ErrorException(code: 0): Creating default object from empty value at /home/digisffl/public_html/core/app/Http/Controllers/AccountController.php:382) – waqar Nov 27 '19 at 13:23
  • yes i am using exact – waqar Nov 27 '19 at 13:24
  • Honestly, I'd probably start popping in some `var_dump()`s for pretty much every var and confirming that they're what you expect. Basic debugging. – Patrick Q Nov 27 '19 at 13:45

0 Answers0