0

I'm setting up a new website, i have this cron job script to automatically update all investment

Error seems to be coming from http controller (line: $rLog['amount'] = round(($rep->invest->amount * $rep->invest->plan->percent) / 100,$basic->deci);).

But i have no idea how to fix it because am totally new to laravel

  if ($basic->repeat_status == 1){

            $repeats = Repeat::whereStatus(0)->get();
            foreach ($repeats as $rep){
                if ($rep->repeat_time < Carbon::now()){

                    $rLog['user_id'] = $rep->user_id;
                    $rLog['trx_id'] = strtoupper(Str::random(20));
                    $rLog['investment_id'] = $rep->investment_id;
                    $rLog['made_time'] = Carbon::now();
                    $rLog['amount'] = round(($rep->invest->amount * $rep->invest->plan->percent) / 100,$basic->deci);
                    RepeatLog::create($rLog);

                    $rep->total_repeat = $rep->total_repeat + 1;
                    $rep->made_time = Carbon::now();
                    $rep->repeat_time = Carbon::parse()->addHours($rep->invest->plan->compound->compound);
                    if ($rep->total_repeat == $rep->invest->plan->time){
                        $rep->status = 1;
                        $inv = Investment::findOrFail($rep->investment_id);
                        $inv->status = 1;
                        $inv->save();
                    }

                    $rep->save();

I expect the cron job script to run and result should be an update in the original investment by user

Hasta Dhana
  • 4,699
  • 7
  • 17
  • 26
Pronet
  • 37
  • 5
  • Have you checked what the intermediate variables contain? Try to dump `$rep->invest` and the rest – Nico Haase May 22 '19 at 07:14
  • Possible duplicate of [Reference - What does this error mean in PHP?](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Nico Haase May 22 '19 at 07:15

2 Answers2

0

I don't think that exception message relate to the cron-job work, It seems to be you have a null property for your object. check and log the value of $rep->invest if that is null then check the value of $rep->invest->plan to find out your problem.

I think one of those things could be null. then after fix them, you may have other problem related to cron-job but it's different story. good lucks.

harunaga
  • 141
  • 1
  • 1
  • 10
  • You are right, i found out it was from the value that wasnt passed correctly from database, Thanks – Pronet May 22 '19 at 11:15
0

you can try $reptime['invest'] ect...

But to turn it in to an object use this code :

json_encode($rep)

because $rep is Problely an array.

Good luck!

Pawel
  • 1
  • 3