<?php namespace app\api\controller; use app\common\controller\Api; use liuniu\UtilService; use think\Exception; use think\Request; use app\common\model\Volunteer as VolunteerModel; class Volunteer extends Api { protected $noNeedRight = ['*']; public function apply(Request $request) { $where = UtilService::postMore( [ ['name', ''], ['phone', ''], ['sex', 0], ['birth', ''], ['image', ''], ['certificateimage', ''], ['email', ''], ['address', ''], ['work', ''], ['specialty', ''], ['education', 0], ['is_vol', 0], ['is_experience', 0], ['start_hour', 7], ['end_hour', 22], ['work_week', '1'], ['taste', ''], ['taste_title', ''], ['speciali', ''], ['speciali_title', ''], ], $request ); // if ($where['name'] == '') $this->error('姓名不能为空'); // if ($where['phone'] == '') $this->error('电话不能为空'); // if ($where['address'] == '') $this->error('地址信息不能为空'); // if ($where['image'] == '') $this->error('照片不能为空'); // if ($where['birth'] == '') $this->error('生日不能为空'); $where['cid'] = $this->cid; $where['user_id'] = $this->auth->getUserinfo()['id']; if (VolunteerModel::where('user_id', $where['user_id'])->where('status', '>', -1)->find()) $this->error('已经存,不能重复申请'); try { if (!VolunteerModel::create($where)) { $this->error(VolunteerModel::getErrorInfo()); } $this->success('创建成功'); } catch (Exception $e) { $this->error($e->getMessage()); } } public function lst() { $this->success('获取成功', VolunteerModel::where('cid', $this->cid)->where('user_id', $this->auth->getUserinfo()['id'])->select()); } }