|
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 App\Models\Game; |
|
11
|
|
|
|
|
12
|
|
|
class DeveloperController extends Controller |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* Display a listing of the resource. |
|
16
|
|
|
* |
|
17
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
18
|
|
|
*/ |
|
19
|
|
|
public function index($orderby = 'devname', $direction = 'asc') |
|
20
|
|
|
{ |
|
21
|
|
|
$rows = (\Auth::check()) ? \Auth::user()->settings->rows_per_page_developer : config('app.rows_per_page_developer'); |
|
22
|
|
|
|
|
23
|
|
|
$developer = \DB::table('developer') |
|
24
|
|
|
->leftJoin('games_developer', 'games_developer.developer_id', '=', 'developer.id') |
|
25
|
|
|
->select([ |
|
26
|
|
|
'developer.id as devid', |
|
27
|
|
|
'developer.name as devname', |
|
28
|
|
|
]) |
|
29
|
|
|
->selectRaw('COUNT(games_developer.id) as gamecount') |
|
30
|
|
|
->groupBy('developer.id') |
|
31
|
|
|
->orderBy($orderby, $direction) |
|
32
|
|
|
->paginate($rows); |
|
33
|
|
|
|
|
34
|
|
|
return view('developer.index', [ |
|
35
|
|
|
'developer' => $developer, |
|
36
|
|
|
'orderby' => $orderby, |
|
37
|
|
|
'direction' => $direction, |
|
38
|
|
|
]); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Display the specified resource. |
|
43
|
|
|
* |
|
44
|
|
|
* @param int $id |
|
45
|
|
|
* |
|
46
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
47
|
|
|
*/ |
|
48
|
|
|
public function show($id, $orderby = 'title', $direction = 'asc') |
|
49
|
|
|
{ |
|
50
|
|
|
$games = Game::with('developers') |
|
51
|
|
|
->leftjoin('games_developer as gd', 'gd.game_id', '=', 'games.id') |
|
52
|
|
|
->Join('developer', 'gd.developer_id', '=', 'developer.id') |
|
53
|
|
|
->where('gd.developer_id', '=', $id) |
|
54
|
|
|
->orderBy($orderby, $direction) |
|
55
|
|
|
->paginate(20, [ |
|
56
|
|
|
'games.*', |
|
57
|
|
|
]); |
|
58
|
|
|
|
|
59
|
|
|
return view('developer.show', [ |
|
60
|
|
|
'games' => $games, |
|
61
|
|
|
'orderby' => $orderby, |
|
62
|
|
|
'direction' => $direction, |
|
63
|
|
|
'id' => $id, |
|
64
|
|
|
]); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.