feat: implement flight show blade and comments flight

This commit is contained in:
2026-08-17 13:08:49 -07:00
parent b14da01731
commit 087070b621
5 changed files with 167 additions and 881 deletions
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\CommentPostRequest;
use App\Models\Comment;
use App\Models\Flight;
use App\Models\Tour;
class CommentController extends Controller
{
public function storeFlight(CommentPostRequest $request, Flight $flight)
{
$this->store($request, ['flight_id' => $flight->id]);
return back()->with('success', 'نظر شما با موفقیت ثبت شد.');
}
public function storeTour(CommentPostRequest $request, Tour $tour)
{
$this->store($request, ['tour_id' => $tour->id]);
return back()->with('success', 'نظر شما با موفقیت ثبت شد.');
}
private function store(CommentPostRequest $request, array $relation)
{
$data = $request->validated();
Comment::create([
...$relation,
'user_id' => auth()->id(),
'guest_name' => auth()->check() ? null : $data['guest_name'],
'guest_email' => auth()->check() ? null : $data['guest_email'],
'comment' => $data['comment'],
'status' => 0,
]);
}
}