Ken 2 days ago
parent
commit
2e012563d5
1 changed files with 21 additions and 0 deletions
  1. 21 0
      app/Models/PcCao.php

+ 21 - 0
app/Models/PcCao.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Models;
+
+class PcCao extends BaseModel
+{
+    protected $table = 'pc_cao';
+    protected $fillable = ['field', 'val'];
+    static function updateData(array $awards)
+    {
+        foreach ($awards as $field) {
+            $cao = static::where('field', $field)->first();
+            if (!$cao) {
+                static::create([
+                    'field' => $field,
+                ]);
+            }
+            $cao->increment('val');
+        }
+    }
+}