Files
ISI2/laravel/app/Http/Controllers/CommentaireController.php
2025-05-27 14:40:41 +02:00

88 lines
2.1 KiB
PHP
Executable File

<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreCommentaireRequest;
use App\Http\Requests\UpdateCommentaireRequest;
use App\Models\Commentaire;
use App\Models\Billet;
use Illuminate\Support\Facades\Log;
class CommentaireController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*/
public function create($idBillet)
{
try {
$billet = Billet::findOrFail($idBillet);
}
catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
Log::channel('projectError')->error('Commentaire : Billet non trouvé');
return view('errors.unavailable');
}
catch (\Illuminate\Database\QueryException $e) {
Log::channel('projectError')->error('Erreur accès base de données');
return view('errors.dberror');
}
return view('vCommenter', compact('idBillet', 'billet'));
}
/**
* Store a newly created resource in storage.
*/
public function store(StoreCommentaireRequest $request)
{
try {
Commentaire::create($request->all());
}
catch (\Illuminate\Database\QueryException $e) {
Log::channel('projectError')->error('Insertion en base de données impossible');
return view('errors.dberror');
}
Log::channel('projectInfo')->info('Commentaire ajouté par : '.$request->ip());
return view('vConfirmStore');
}
/**
* Display the specified resource.
*/
public function show(Commentaire $commentaire)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Commentaire $commentaire)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateCommentaireRequest $request, Commentaire $commentaire)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Commentaire $commentaire)
{
//
}
}