<?php

namespace App\Http\Controllers;

use App\Models\Document;
use App\Models\DocumentComment;
use Illuminate\Http\Request;

class DocumentCommentController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request, Document $document)
    {
        $request->validate([
            'content' => 'required|string|max:1000',
            'page' => 'required|integer|min:1',
            'x' => 'required|numeric|between:0,1',
            'y' => 'required|numeric|between:0,1'
        ]);

        $document->comments()->create([
            'user_id' => auth()->id(),
            'content' => $request->content,
            'page' => $request->page,
            'x' => $request->x,
            'y' => $request->y,
            'parent_id' => $request->parent_id
        ]);

        return back();
    }

    /**
     * Display the specified resource.
     */
    public function show(DocumentComment $documentComment)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit(DocumentComment $documentComment)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, DocumentComment $documentComment)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(DocumentComment $documentComment)
    {
        //
    }
}
