<?php

namespace App\Http\Controllers\Api\mini;

use App\Models\UserAuth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class UserAuthController extends BaseController
{
    protected $model;

    public function __construct()
    {
        $this->model = new UserAuth();
    }

    public function create(Request $request)
    {
        $data = $request->only(['name', 'project_id', 'project_role_id', 'remark', 'phone']);
        $user = Auth::guard('mini')->user();
        $user_id = $user ? $user->id : '';
        $data['active'] = 2;
        $user = $this->model->firstOrCreate([
            'user_id' => $user_id
        ], $data);
        $user->update($data);
        return $this->success(['data' => '操作成功']);
    }
}
