Passed
Push — develop ( 440a15...e4ddd7 )
by Nikita
09:36
created

GameModRepository::getIdNameListForGame()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 1
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Gameap\Repositories;
4
5
use Gameap\Models\GameMod;
6
7
class GameModRepository extends Repository
8
{
9 9
    public function __construct(GameMod $gameMod)
10
    {
11 9
        $this->model = $gameMod;
12 9
    }
13
14
    public function getAll($perPage = 20)
15
    {
16
        return GameMod::orderBy('id')->paginate($perPage);
17
    }
18
19
    public function getById(int $id): GameMod
20
    {
21
        return GameMod::findOrFail($id);
22
    }
23
24
    /**
25
     * @param string $gameCode
26
     * @return array
27
     */
28
    public function getIdNameListForGame(string $gameCode)
29
    {
30
        return $this->model->select('id', 'name')
31
            ->where('game_code', '=', $gameCode)
32
            ->orderBy('name')
33
            ->get();
34
    }
35
}
36