<?php
/**
 * Created by PhpStorm.
 * User: Yuanhang Liu
 * Date: 20-10-14
 * Time: 上午00:01
 */

namespace App\Http\Controllers\Api\V2;

use App\Models\ServiceApply;

/**
 * 服务设置类
 * Class ServiceApplyController
 * @package App\Http\Controllers\Api\V2
 */
class ServiceApplyController extends AuthController
{
    /**
     * 服务设置审核
     */
    public function serviceExamine(){
        $req = request()->post();
        $this->validate(request(), [
            'service_type' => 'required|integer',
        ]);
        $user = $this->user;
        $doctor_id = $user['id'];

        $where['docter_id'] = $doctor_id;
        $where['service_type'] = $req['service_type'];
        $data = ServiceApply::where($where)->first();
        if(empty($data)){
            ServiceApply::create([
                'docter_id' => $doctor_id,
                'service_type' => $req['service_type'],
                'status' => 1   //审核状态 1 审核 2 已通过 3 已拒绝
            ]);
            return out();
        }else{
            return out('','','您已提交');
        }
    }
}
