DeveloperController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 55
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 21 2
A show() 0 18 1
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
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
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
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
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