|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Models\Game; |
|
6
|
|
|
use App\Models\UserReport; |
|
7
|
|
|
use Carbon\Carbon; |
|
8
|
|
|
use Illuminate\Http\Request; |
|
9
|
|
|
|
|
10
|
|
|
class ReportController extends Controller |
|
11
|
|
|
{ |
|
12
|
|
|
public function index() { |
|
13
|
|
|
$r = UserReport::all(); |
|
14
|
|
|
|
|
15
|
|
|
return view('reports.index', [ |
|
16
|
|
|
'reports' => $r, |
|
17
|
|
|
]); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function create_game_report($gameid) { |
|
21
|
|
|
$g = Game::whereId($gameid)->first(); |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
return view('reports.create', [ |
|
24
|
|
|
'game' => $g, |
|
25
|
|
|
]); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function store_game_report(Request $request, $gameid) { |
|
29
|
|
|
$r = new UserReport; |
|
|
|
|
|
|
30
|
|
|
$r->content_id = $gameid; |
|
|
|
|
|
|
31
|
|
|
$r->content_type = 'game'; |
|
32
|
|
|
$r->reason = $request->get('msg'); |
|
|
|
|
|
|
33
|
|
|
$r->user_id = \Auth::id(); |
|
|
|
|
|
|
34
|
|
|
$r->save(); |
|
35
|
|
|
|
|
36
|
|
|
return redirect()->action('ReportController@index_user'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function index_user() { |
|
40
|
|
|
if(\Auth::check()){ |
|
41
|
|
|
if(\Auth::user()->can('admin-games')){ |
|
42
|
|
|
$ur = UserReport::all(); |
|
43
|
|
|
}else{ |
|
44
|
|
|
$ur = UserReport::whereUserId(\Auth::id()); |
|
45
|
|
|
} |
|
46
|
|
|
}else{ |
|
47
|
|
|
$ur = null; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
return view('reports.index', [ |
|
51
|
|
|
'reports' => $ur, |
|
52
|
|
|
]); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
View Code Duplication |
public function close_ticket($id){ |
|
|
|
|
|
|
56
|
|
|
$t = UserReport::whereId($id); |
|
|
|
|
|
|
57
|
|
|
$t->closed = 1; |
|
|
|
|
|
|
58
|
|
|
$t->closed_at = Carbon::now(); |
|
|
|
|
|
|
59
|
|
|
$t->closed_user_id = \Auth::id(); |
|
60
|
|
|
$t->save(); |
|
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
return redirect()->action('ReportController@index_user'); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
View Code Duplication |
public function open_ticket($id){ |
|
|
|
|
|
|
66
|
|
|
$t = UserReport::whereId($id); |
|
|
|
|
|
|
67
|
|
|
$t->closed = 0; |
|
|
|
|
|
|
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
|
|
|
public function remark_ticket($id){ |
|
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: