Issues (374)

app/Models/DownloadStat.php (2 issues)

1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Factories\HasFactory;
6
use Illuminate\Database\Eloquent\Model;
7
8
class DownloadStat extends Model
9
{
10
    use HasFactory;
0 ignored issues
show
The trait Illuminate\Database\Eloquent\Factories\HasFactory requires the property $factoryClass which is not provided by App\Models\DownloadStat.
Loading history...
11
12
    protected $guarded = [];
13
14
    public static function insertTopDownloads(): void
15
    {
16
        $releases = Release::query()
17
            ->where('grabs', '>', 0)
18
            ->select(['id', 'searchname', 'guid', 'adddate'])
19
            ->selectRaw('SUM(grabs) as grabs')
20
            ->groupBy('id', 'searchname', 'adddate')
21
            ->havingRaw('SUM(grabs) > 0')
22
            ->orderByDesc('grabs')
0 ignored issues
show
'grabs' of type string is incompatible with the type Closure|Illuminate\Datab...\Database\Query\Builder expected by parameter $column of Illuminate\Database\Query\Builder::orderByDesc(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
            ->orderByDesc(/** @scrutinizer ignore-type */ 'grabs')
Loading history...
23
            ->limit(10)
24
            ->get();
25
26
        foreach ($releases as $release) {
27
            self::updateOrCreate([
28
                'searchname' => $release->searchname,
29
                'guid' => $release->guid,
30
                'adddate' => $release->adddate,
31
                'grabs' => $release->grabs,
32
            ]);
33
        }
34
    }
35
36
    public static function getTopDownloads(): array
37
    {
38
        return self::query()->select(['searchname', 'guid', 'adddate', 'grabs'])->get()->toArray();
39
    }
40
}
41