weigh == 0) { $pk = $model->getPk(); if (strlen($model[$pk]) >= 19) { $model->where($pk, $model[$pk])->update(['weigh' => $model->count()]); } else { $model->where($pk, $model[$pk])->update(['weigh' => $model[$pk]]); } } } public function getRatioAttr($value): float { return (float)$value; } public function admin() { return $this->belongsTo(\app\admin\model\Admin::class, 'user_id', 'id'); } }