<?php

namespace App\Admin\Actions\backstage;
use App\Models\DocterOrganization;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;

class Refuse extends RowAction
{
    public $name = '驳回';

    public function handle(Model $model)
    {
        // $model ...
        DocterOrganization::where('id',$model->id)->update(['state'=>2,'authentication_time'=>0,'authentication_end_time'=>0]);

        $openid = $this->row->docter->openid;

        $data = [
            $openid,
            '',
            '很抱歉，你的医生身份认证失败！',
            $this->row->docter->name,
            $this->row->organization->name,
            $this->row->qualification->name,
            $this->row->office->name,
            '点击进入小程序查看详情，有疑问请联系管理员！'
        ];
        if(!empty($openid)){
            admin_send_docter_message('then_result',$data);
        }

        return $this->response()->success('审核驳回')->refresh();
    }

}
