78a3b1d63d
git commit "Add admin management search sort and permission structure preparation"
40 lines
898 B
PHP
40 lines
898 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\CommentStoreRequest;
|
|
use App\Models\Comment;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class CommentController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$withoutHero=true;
|
|
|
|
$comments=Comment::query()
|
|
->where('user_id',auth()->id())
|
|
->with('tour')
|
|
->latest()
|
|
->paginate(4);
|
|
|
|
return view('account.users.comments.index',compact('withoutHero','comments'));
|
|
}
|
|
|
|
public function store(CommentStoreRequest $request)
|
|
{
|
|
$data = $request->validated();
|
|
|
|
$data['user_id'] = auth()->id();
|
|
$data['status'] = 0;
|
|
|
|
Comment::create($data);
|
|
|
|
return back()->with(
|
|
'success',
|
|
'نظر شما با موفقیت ثبت شد و پس از بررسی نمایش داده میشود.'
|
|
);
|
|
|
|
}
|
|
}
|