1 | <?php |
||||
2 | |||||
3 | namespace App\Models; |
||||
4 | |||||
5 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
||||
6 | use Illuminate\Database\Eloquent\Model; |
||||
7 | |||||
8 | class GrabStat extends Model |
||||
9 | { |
||||
10 | use HasFactory; |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
11 | |||||
12 | protected $guarded = []; |
||||
13 | |||||
14 | public static function insertTopGrabbers(): void |
||||
15 | { |
||||
16 | $users = User::query()->selectRaw('id, username, SUM(grabs) as grabs')->groupBy('id', 'username')->having('grabs', '>', 0)->orderByDesc('grabs')->limit(10)->get(); |
||||
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
![]() |
|||||
17 | // Insert data into the grab_stats table |
||||
18 | foreach ($users as $user) { |
||||
19 | self::updateOrCreate(['username' => $user->username], ['grabs' => $user->grabs]); |
||||
20 | } |
||||
21 | } |
||||
22 | |||||
23 | public static function getTopGrabbers(): array |
||||
24 | { |
||||
25 | return self::query()->select(['username', 'grabs'])->get()->toArray(); |
||||
26 | } |
||||
27 | } |
||||
28 |