feat: complete flightShow and comments flight

This commit is contained in:
2026-08-17 14:05:14 -07:00
parent 318a79e278
commit ff50fe1a95
3 changed files with 31 additions and 20 deletions
+5 -4
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Enums\CommentStatus;
use App\Http\Requests\CommentPostRequest;
use App\Models\Comment;
use App\Models\Flight;
@@ -13,14 +14,14 @@ class CommentController extends Controller
{
$this->store($request, ['flight_id' => $flight->id]);
return back()->with('success', 'نظر شما با موفقیت ثبت شد.');
return back()->withErrors([ 'success' => 'نظر شما با موفقیت ثبت شد.' ]);
}
public function storeTour(CommentPostRequest $request, Tour $tour)
{
$this->store($request, ['tour_id' => $tour->id]);
return back()->with('success', 'نظر شما با موفقیت ثبت شد.');
return back()->withErrors([ 'success' => 'نظر شما با موفقیت ثبت شد.' ]);
}
private function store(CommentPostRequest $request, array $relation)
@@ -28,12 +29,12 @@ class CommentController extends Controller
$data = $request->validated();
Comment::create([
...$relation,
$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,
'status' => CommentStatus::APPROVED,
]);
}
-5
View File
@@ -25,11 +25,6 @@ class CommentPostRequest extends FormRequest
$isGuest = !auth()->check();
return [
'rating' => [
'required',
'integer',
'between:1,5',
],
'comment' => [
'required',
+26 -11
View File
@@ -5,20 +5,27 @@
<h5>بازخوردها</h5>
@forelse($comments as $comment)
@forelse($flight->comments as $comment)
<div class="listing-review-item">
<div class="listing-review-author">
<img
src="{{ $comment->user->file ? asset('storage/'.$comment->user->file->path) : asset('assets/img/account/01.jpg') }}"
src="{{ $comment->user && $comment->user->file
? asset('storage/'.$comment->user->file->path)
: asset('assets/img/account/01.jpg') }}"
alt
>
<div class="listing-review-author-info">
<div>
<h6>
{{ $comment->user->first_name }}
{{ $comment->user->last_name }}
@if($comment->user)
{{ $comment->user->first_name }}
{{ $comment->user->last_name }}
@else
{{ $comment->guest_name }}
@endif
</h6>
<span>
@@ -27,6 +34,7 @@
</span>
</div>
</div>
</div>
<p>{{ $comment->comment }}</p>
@@ -41,6 +49,13 @@
<div class="listing-review-form">
<h4>نظر بدهید</h4>
@error('success')
<div class="alert alert-success">
{{ $message }}
</div>
@enderror
<form action="{{ route('flights.comments', $flight) }}" method="POST">
@csrf
@@ -67,13 +82,13 @@
@endguest
<div class="form-group">
<textarea
name="comment"
class="form-control"
cols="30"
rows="5"
placeholder="نظر خود را بنویسید*"
>{{ old('comment') }}</textarea>
<textarea
name="comment"
class="form-control"
cols="30"
rows="5"
placeholder="نظر خود را بنویسید*"
>{{ old('comment') }}</textarea>
</div>
<button class="theme-btn" type="submit">