Issues (378)

app/Models/DnzbFailure.php (1 issue)

1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\BelongsTo;
7
8
/**
9
 * App\Models\DnzbFailure.
10
 *
11
 * @property int $release_id
12
 * @property int $users_id
13
 * @property int $failed
14
 * @property-read Release $release
15
 * @property-read User $user
16
 *
17
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DnzbFailure whereFailed($value)
18
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DnzbFailure whereReleaseId($value)
19
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DnzbFailure whereUsersId($value)
20
 *
21
 * @mixin \Eloquent
22
 *
23
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DnzbFailure newModelQuery()
24
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DnzbFailure newQuery()
25
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DnzbFailure query()
26
 */
27
class DnzbFailure extends Model
28
{
29
    /**
30
     * @var string
31
     */
32
33
    /**
34
     * @var bool
35
     */
36
    protected $dateFormat = false;
37
38
    /**
39
     * @var bool
40
     */
41
    public $timestamps = false;
42
43
    /**
44
     * @var bool
45
     */
46
    public $incrementing = false;
47
48
    /**
49
     * @var array
50
     */
51
    protected $guarded = [];
52
53
    public function release(): BelongsTo
54
    {
55
        return $this->belongsTo(Release::class, 'release_id');
56
    }
57
58
    public function user(): BelongsTo
59
    {
60
        return $this->belongsTo(User::class, 'users_id');
61
    }
62
63
    /**
64
     * Read failed downloads count for requested release_id.
65
     *
66
     *
67
     * @return bool|mixed
68
     */
69
    public static function getFailedCount($relId)
70
    {
71
        $result = self::query()->where('release_id', $relId)->value('failed');
72
        if (! empty($result)) {
73
            return $result;
74
        }
75
76
        return false;
77
    }
78
79
    public static function getCount(): int
80
    {
81
        return self::query()->count('release_id');
0 ignored issues
show
Bug Best Practice introduced by
The expression return self::query()->count('release_id') could return the type Illuminate\Database\Eloquent\Builder which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
82
    }
83
}
84