|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* rmarchiv.tk |
|
5
|
|
|
* (c) 2016-2017 by Marcel 'ryg' Hering |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace App\Http\Controllers; |
|
9
|
|
|
|
|
10
|
|
|
use Carbon\Carbon; |
|
11
|
|
|
use App\Models\Game; |
|
12
|
|
|
use App\Models\UserReport; |
|
13
|
|
|
use Illuminate\Http\Request; |
|
14
|
|
|
|
|
15
|
|
|
class ReportController extends Controller |
|
16
|
|
|
{ |
|
17
|
|
|
public function index() |
|
18
|
|
|
{ |
|
19
|
|
|
$r = UserReport::all(); |
|
20
|
|
|
|
|
21
|
|
|
return view('reports.index', [ |
|
22
|
|
|
'reports' => $r, |
|
23
|
|
|
]); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function create_game_report($gameid) |
|
27
|
|
|
{ |
|
28
|
|
|
$g = Game::whereId($gameid)->first(); |
|
29
|
|
|
|
|
30
|
|
|
return view('reports.create', [ |
|
31
|
|
|
'game' => $g, |
|
32
|
|
|
]); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function store_game_report(Request $request, $gameid) |
|
36
|
|
|
{ |
|
37
|
|
|
$r = new UserReport(); |
|
|
|
|
|
|
38
|
|
|
$r->content_id = $gameid; |
|
|
|
|
|
|
39
|
|
|
$r->content_type = 'game'; |
|
40
|
|
|
$r->reason = $request->get('msg'); |
|
|
|
|
|
|
41
|
|
|
$r->user_id = \Auth::id(); |
|
|
|
|
|
|
42
|
|
|
$r->save(); |
|
43
|
|
|
|
|
44
|
|
|
return redirect()->action('ReportController@index_user'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function index_user() |
|
48
|
|
|
{ |
|
49
|
|
|
if (\Auth::check()) { |
|
50
|
|
|
if (\Auth::user()->can('admin-games')) { |
|
51
|
|
|
$ur = UserReport::all(); |
|
52
|
|
|
} else { |
|
53
|
|
|
$ur = UserReport::whereUserId(\Auth::id()); |
|
54
|
|
|
} |
|
55
|
|
|
} else { |
|
56
|
|
|
$ur = null; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
return view('reports.index', [ |
|
60
|
|
|
'reports' => $ur, |
|
61
|
|
|
]); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
View Code Duplication |
public function close_ticket($id) |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
$t = UserReport::whereId($id)->first(); |
|
|
|
|
|
|
67
|
|
|
$t->closed = 1; |
|
|
|
|
|
|
68
|
|
|
$t->closed_at = Carbon::now(); |
|
|
|
|
|
|
69
|
|
|
$t->closed_user_id = \Auth::id(); |
|
70
|
|
|
$t->save(); |
|
71
|
|
|
|
|
72
|
|
|
return redirect()->action('ReportController@index_user'); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
View Code Duplication |
public function open_ticket($id) |
|
|
|
|
|
|
76
|
|
|
{ |
|
77
|
|
|
$t = UserReport::whereId($id)->first(); |
|
|
|
|
|
|
78
|
|
|
$t->closed = 0; |
|
|
|
|
|
|
79
|
|
|
$t->closed_at = Carbon::now(); |
|
|
|
|
|
|
80
|
|
|
$t->closed_user_id = \Auth::id(); |
|
81
|
|
|
$t->save(); |
|
82
|
|
|
|
|
83
|
|
|
return redirect()->action('ReportController@index_user'); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function remark_ticket($id) |
|
|
|
|
|
|
87
|
|
|
{ |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.