<?php

namespace App\Http\Controllers\H5;

use App\Http\Controllers\Controller;
use App\Http\Requests\ModeratorRequest;
use App\Http\Response\ResponseJson;
use App\Models\Moderator;
use Illuminate\Http\Request;

class ModeratorController extends Controller
{
    use ResponseJson;

    public function store(ModeratorRequest $request)
    {
        $data = $request->validated();
        $user = auth()->user();
        $data = array_merge($data, ['status'=>0]);
        $moderator = Moderator::where("user_id", $user->id)->updateOrCreate(['user_id'=>$user->id], $data);
        return $this->success('ok', $moderator);
    }

    public function show()
    {
        $user = auth()->user();
        $moderator = Moderator::where('user_id', $user->id)->first();
        return $this->success('ok', $moderator);
    }
}
