feat: complete flightShow and comments flight
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,6 @@ class CommentPostRequest extends FormRequest
|
||||
$isGuest = !auth()->check();
|
||||
|
||||
return [
|
||||
'rating' => [
|
||||
'required',
|
||||
'integer',
|
||||
'between:1,5',
|
||||
],
|
||||
|
||||
'comment' => [
|
||||
'required',
|
||||
|
||||
@@ -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>
|
||||
@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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user