70d4767890
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
938 B
PHP
37 lines
938 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Web;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\EmotionRecord;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class EmotionController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$records = EmotionRecord::where('user_id', Auth::id())->latest()->get();
|
|
|
|
return view('emotions.index', compact('records'));
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$request->validate([
|
|
'emotion' => 'required|string',
|
|
'intensity' => 'required|integer|min:1|max:5',
|
|
'note' => 'nullable|string',
|
|
]);
|
|
|
|
EmotionRecord::create([
|
|
'user_id' => Auth::id(),
|
|
'emotion' => $request->emotion,
|
|
'intensity' => $request->intensity,
|
|
'note' => $request->note,
|
|
]);
|
|
|
|
return redirect()->back()->with('success', 'Émotion enregistrée');
|
|
}
|
|
}
|