douyun1972 2019-05-22 07:11
浏览 89
已采纳

我得到“ErrorException(E_NOTICE)试图获取非对象的属性”试图运行一个cron作业脚本

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

  • 写回答

2条回答 默认 最新

  • dongshan7060 2019-05-22 08:21
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 基于52单片机的酒精浓度检测系统加继电器和sim800
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答