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
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.
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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.