codeplus / core /app /Http /Controllers /Admin /CommentController.php
Softin Trading
Initial commit from Github
52d9fb0
Raw History Blame Contribute Delete
1.32 kB
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Comment;
use Illuminate\Http\Request;
class CommentController extends Controller
{
public function index($authorId = 0)
{
$pageTitle = 'Comments';
$comments = Comment::where('review_id', 0)->with(['user', 'product']);
if($authorId){
$comments = $comments->where('user_id', $authorId);
}
$comments = $comments->paginate(getPaginate());
return view('admin.comment.index', compact('pageTitle', 'comments'));
}
public function destroy($id) {
$comment = Comment::findOrFail($id);
$comment->delete();
$notify[] = ['success', 'Comment deleted'];
return back()->withNotify($notify);
}
public function repliesList($commentId) {
$pageTitle = 'Replies';
$comment = Comment::findOrFail($commentId);
$replies = $comment->replies()->with(['user', 'product'])->paginate(getPaginate());
return view('admin.comment.reply.index', compact('pageTitle', 'replies'));
}
public function deleteReply($id) {
$comment = Comment::findOrFail($id);
$comment->delete();
$notify[] = ['success','Reply deleted'];
return back()->withNotify($notify);
}
}