<?php

namespace app\home\controller;

use app\common\model\RecruitAppointBasicModel;
use app\home\HomeBaseController;

class My extends HomeBaseController
{
    protected function init()
    {
        $this->checkLogin();
    }

    public function index()
    {
        return view();
    }

    public function info()
    {
        $info = RecruitAppointBasicModel::where('user_id', $this->user['id'])->find();
        if (empty($info)) {
            $info = [
                'realname'              => '',
                'sex'                   => 1,
                'birthday'              => '',
                'avatar'                => '',
                'nation'                => '',
                'native_place'          => '',
                'political_affiliation' => '',
                'titles'                => '',
                'work'                  => '',
                'house_register'        => '',
                'join_time'             => '',
                'edu_type'              => '',
                'education'             => '',
                'school'                => '',
                'degree'                => '',
                'pro'                   => '',
                'province'              => '',
                'city'                  => '',
                'area'                  => '',
                'address'               => '',
                'card'                  => '',
                'mobile'                => '',
                'email'                 => '',
                'concat_name'           => '',
                'concat_mobile'         => '',
                'resume'                => '',
                'family'                => [
                    [
                        'relation'              => '',
                        'realname'              => '',
                        'birthday'              => '',
                        'political_affiliation' => '',
                        'work'                  => '',
                    ],
                ],
                'is_push'               => 1,
            ];
        }
        return view('', ['info' => json_encode($info)]);
    }

    public function infoPost()
    {
        $basic = RecruitAppointBasicModel::where('user_id',$this->user['id'])->find();
        $data = input('post.');
        if ($basic) {
            //更新基础信息
            unset($data['create_time'],$data['update_time']);
            RecruitAppointBasicModel::where('user_id', $this->user['id'])->update($data);
        } else {
            //新增基础信息
            $data['user_id'] = $this->user['id'];
            RecruitAppointBasicModel::create($data);
        }
        ajax_return(0,'个人基础信息保存成功，快去报名吧！');
    }

    public function account()
    {
        return view();
    }

    public function tip()
    {
        return view();
    }

    public function feedback()
    {
        return view();
    }
}
