Passed
Push — master ( 683e46...62b981 )
by Iman
05:04 queued 01:04
created

ApiKeysRepository::incrementHit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace crocodicstudio\crudbooster\Modules\ApiGeneratorModule;
4
5
use Illuminate\Support\Facades\DB;
6
7
class ApiKeysRepository
8
{
9
    public static function incrementHit($serverSecret)
10
    {
11
        return self::table()->where('secretkey', $serverSecret)->increment('hit');
12
    }
13
14
    public static function getSecretKeys()
15
    {
16
        return self::table()->where('status', 'active')->pluck('Secretkey');
17
    }
18
19
    public static function get()
20
    {
21
        return self::table()->get();
22
    }
23
24
    public static function deleteById($id)
25
    {
26
        return self::table()->where('id', $id)->delete();
27
    }
28
29
    public static function updateById($status, $id)
30
    {
31
        return self::table()->where('id', $id)->update(['status' => $status]);
32
    }
33
34
    public static function insertGetId($token)
35
    {
36
        return self::table()->insertGetId([
37
            'secretkey' => $token,
38
            'created_at' => date('Y-m-d H:i:s'),
39
            'status' => 'active',
40
            'hit' => 0,
41
        ]);
42
    }
43
44
    private static function table()
45
    {
46
        return DB::table('cms_apikey');
47
    }
48
}