<?php

namespace Modules\User\Http\Controllers\Admin\Actions\Certification;

use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use Modules\User\Models\UserCertificationConfig;

class ConfigPublish extends RowAction
{
    public $name = '使用配置';

    public function handle(Model $model)
    {
        UserCertificationConfig::where('id', '<>', $model->id)->update(['status' => 0]);
        $model->status = 1;
        $model->save();

        return $this->response()->success('发布配置完成')->refresh();
    }

    public function dialog()
    {
        $this->confirm('确定使用配置么？');
    }
}