Passed
Push — develop ( fc9ba3...3655e4 )
by Nikita
04:54
created

GamesController::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Gameap\Http\Controllers\API;
4
5
use Gameap\Http\Controllers\AuthController;
6
use Gameap\Models\Game;
7
use Gameap\Repositories\GameRepository;
8
use Illuminate\Http\Request;
9
10
class GamesController extends AuthController
11
{
12
    /**
13
     * The GameRepository instance.
14
     *
15
     * @var \Gameap\Repositories\GameRepository
16
     */
17
    public $repository;
18
19
    /**
20
     * GamesController constructor.
21
     * @param GameRepository $repository
22
     */
23
    public function __construct(GameRepository $repository)
24
    {
25
        parent::__construct();
26
27
        $this->repository = $repository;
28
    }
29
30
    public function index()
31
    {
32
        $games = Game::all();
33
34
        return response()->json($games);
35
    }
36
37
    public function store(Request $request)
38
    {
39
        $game = Game::create($request->all());
40
41
        return response()->json($game, 201);
42
    }
43
44
    public function show(Game $game)
45
    {
46
        return response()->json($game);
47
    }
48
49
    public function update(Request $request, Game $game)
50
    {
51
        $game->update($request->all());
52
53
        return response()->json($game, 200);
54
    }
55
56
    public function destroy(Game $game)
57
    {
58
        $game->delete();
59
60
        return response()->json(null, 204);
61
    }
62
}
63