fix: update account comment handling

This commit is contained in:
2026-08-22 07:52:16 +03:30
parent 7c0bc5b08b
commit cb494a933e
2 changed files with 41 additions and 12 deletions
@@ -1,13 +1,47 @@
<?php
namespace App\Http\Controllers\Account;
use App\Http\Requests\CommentStoreRequest;
use App\Http\Controllers\Controller;
use App\Models\Flight;
use App\Models\Tour;
class CommentController extends Controller
{
public function index()
//ثبت نظر برای تور
public function storeTour(CommentStoreRequest $request, Tour $tour)
{
return view('account.comments');
$tour->comments()->create([
'user_id' => auth()->id(),
'body' => $request->validated('body'),
'status' => 1, // در انتظار تایید (طبق قرارداد: 1 = پیشنویس/فعال، 2 = منتشرشده)
]);
return back()->with('success', 'نظر شما با موفقیت ثبت شد.');
}
//ثبت نظر برای پرواز
public function storeFlight(CommentStoreRequest $request, Flight $flight)
{
$flight->comments()->create([
'user_id' => auth()->id(),
'body' => $request->validated('body'),
'status' => 1,
]);
return back()->with('success', 'نظر شما با موفقیت ثبت شد.');
}
public function myComments()
{
$comments = auth()->user()->comments()
->with('commentable')
->latest()
->paginate(10);
return view('account.comments', compact('comments'));
}
}