feat:complete comments in tourShow

This commit is contained in:
2026-08-17 18:20:38 -07:00
parent c070681830
commit 914c1aedbd
3 changed files with 55 additions and 7 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ 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'],
+14 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Enums\CommentStatus;
use App\Enums\TourStatus;
use App\Models\Tour;
use Illuminate\Http\Request;
@@ -20,8 +21,20 @@ class TourController extends Controller
return view('tours.index', compact('tours'));
}
public function show()
public function show(Tour $tour)
{
abort_if($tour->status !== TourStatus::ENABLE->value, 404);
$tour->increment('views');
$tour->load(['file',
'comments' => function ($query) {
$query->where('status', CommentStatus::APPROVED)
->with('user')
->orderByDesc('created_at');
},]);
return view('tours.show', compact('tour'));
}
}