48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?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 storeTour(CommentStoreRequest $request, Tour $tour)
|
|
{
|
|
$tour->comments()->create([
|
|
'user_id' => auth()->id(),
|
|
'body' => $request->validated('body'),
|
|
'status' => 1,
|
|
]);
|
|
|
|
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'));
|
|
}
|
|
}
|