<?php

namespace app\admin\model;

use app\common\model\TimeModel;
use think\Model;

class SystemConfig extends TimeModel
{
    public static function onBeforeUpdate(Model $model): void
    {
        if ($model->getData('name') === 'upload_allow_ext') {
            //去除 php
            $model->value = implode(',',array_map(function ($ext) {
                return trim(strtolower($ext), ' ');
            }, array_filter(explode(',', $model->getData('value')), function ($ext) {
                return strtolower(trim($ext)) !== 'php';
            })));
        }
    }
}