update init category icon_id

This commit is contained in:
xiaomlove
2021-05-29 21:48:50 +08:00
parent 3a54de8be7
commit 8e35dc0886
5 changed files with 35 additions and 11 deletions
+8
View File
@@ -2,6 +2,8 @@
namespace Nexus\Install;
use App\Models\Category;
use App\Models\Icon;
use Nexus\Database\DB;
class Update extends Install
@@ -62,6 +64,12 @@ class Update extends Install
$id = DB::insert($table, $insert);
$this->doLog("[ADD CUSTOM FIELD MENU] insert: " . json_encode($insert) . " to table: $table, id: $id");
}
if (WITH_LARAVEL && DB::schema()->hasColumn('categories', 'icon_id')) {
$icon = Icon::query()->orderBy('id', 'asc')->first();
if ($icon) {
Category::query()->where('icon_id', 0)->update(['icon_id' => $icon->id]);
}
}
}
}