Last change
on this file since c433da6 was 0924b6c, checked in by Özkan İliyaz <iliyaz_96@…>, 4 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[0924b6c] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | namespace App\Http\Controllers\Dashboard;
|
---|
| 4 |
|
---|
| 5 | use App\Helpers\Alert;
|
---|
| 6 | use App\Models\Post;
|
---|
| 7 | use App\Models\Comment;
|
---|
| 8 | use Illuminate\Http\Request;
|
---|
| 9 | use App\Http\Controllers\Controller;
|
---|
| 10 |
|
---|
| 11 | class 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.