<?php

namespace App\Http\Controllers\User;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class StudyLogController extends Controller
{
    public function store(Request $request)
    {
        $validated = $request->validate([
            'title' => ['required', 'string', 'max:255'],
            'duration' => ['required', 'integer', 'min:1'],
        ]);

        \App\Models\StudyLog::create([
            'user_id' => $request->user()->id,
            'title' => $validated['title'],
            'duration' => $validated['duration'],
        ]);

        return back()->with('success', 'Study log added.');
    }
}
