<?php
/**
 * Created by PhpStorm.
 * User: zilongs
 * Date: 20-9-23
 * Time: 上午11:36
 */

namespace App\Http\Controllers\Api\V2;

use App\Models\Order;
use App\Models\User;
use App\Models\Docter;
use App\Models\UserBalanceLog;
use EasyWeChat\Factory;
use Illuminate\Support\Facades\DB;

/**
 * 用户类
 * Class UserController
 * @package App\Http\Controllers\Api\V2
 */
class UserController extends AuthController
{
    public function userInfo()
    {
        $user = $this->user;

        unset($user['session_key']);

        return out($user);
    }



    public function updateUser()
    {
        $req = request()->post();
        $this->validate(request(), [
            'nickname' => 'max:100',
            'avatar' => 'url',
            'sex' => 'in:1,2',
            'birthday' => 'date',
            'latitude' => 'numeric',
            'longitude' => 'numeric',
        ]);
        $user = $this->user;
        User::where('id', $user['id'])->update($req);
        return out();
    }

    public function userBalanceLog()
    {
        $user = $this->user;
        $data = UserBalanceLog::where('user_id', $user['id'])->orderBy('id', 'desc')->paginate();
        return out($data);
    }

}
