$yesterday, "un_weigh_count" => 0, "total_count" => 0 ]; else $obj = [ "targeted_at" => $result->date, "un_weigh_count" => $result->count, "total_count" => $result->total, ]; /** @var \stdClass $model */ $model = OrderPackageCountingRecord::query()->create($obj); Cache::put("weight.".$yesterday,[ "date"=>$yesterday, "total"=>$model->total_count, "count"=>$model->un_weigh_count, "value"=>$model->total_count ? intval(($model->un_weigh_count/$model->total_count)*100) : 0 ]); } }