source: app/Http/Controllers/Dashboard/CommentsController.php@ 0924b6c

Last change on this file since 0924b6c was 0924b6c, checked in by Özkan İliyaz <iliyaz_96@…>, 4 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[0924b6c]1<?php
2
3namespace App\Http\Controllers\Dashboard;
4
5use App\Helpers\Alert;
6use App\Models\Post;
7use App\Models\Comment;
8use Illuminate\Http\Request;
9use App\Http\Controllers\Controller;
10
11class CommentsController extends Controller
12{
13 public function index()
14 {
15 $comments = collect();
16
17 if (auth()->user()->hasPermission("approve_all_comments")) {
18 $comments = Comment::all();
19 } else {
20 $comments = auth()->user()->comments;
21 }
22
23 return view("dashboard.comments.index")->with([
24 "comments" => $comments]
25 );
26 }
27
28 public function confirm(Request $request, $id)
29 {
30 $comment = Comment::find($id);
31 $comment->is_active = true;
32 $comment->confirmed_date = now();
33 $comment->save();
34
35 Alert::flash("Comment confirmed successfully");
36
37 return redirect()->route("dashboard.comments.index");
38 }
39
40 public function destroy(Request $request, $id)
41 {
42 Comment::find($id)->delete();
43 Alert::flash("Comment deleted successfully");
44 return redirect()->route("dashboard.comments.index");
45 }
46}
Note: See TracBrowser for help on using the repository browser.