Skip to content

Commit 2b5d924

Browse files
authored
Merge pull request #3774 from HDInnovations/Laravel-11
(Update) Laravel 11
2 parents ed392eb + bd54a23 commit 2b5d924

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+894
-910
lines changed

.env.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ DB_USERNAME=root
1717
DB_PASSWORD=
1818
#PRISTINE_DB_FILE=/home/vagrant/code/database/unit3d_test.sql
1919

20-
BROADCAST_DRIVER=redis
21-
CACHE_DRIVER=redis
20+
BROADCAST_CONNECTION=redis
21+
CACHE_STORE=redis
2222
SESSION_DRIVER=redis
2323
SESSION_CONNECTION=session
2424
SESSION_LIFETIME=120

app/Console/Commands/AutoGroup.php

+16-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace App\Console\Commands;
1515

1616
use App\Enums\UserGroup;
17-
use App\Helpers\ByteUnits;
1817
use App\Models\Group;
1918
use App\Models\User;
2019
use App\Services\Unit3dAnnounce;
@@ -44,11 +43,11 @@ class AutoGroup extends Command
4443
/**
4544
* Execute the console command.
4645
*/
47-
public function handle(ByteUnits $byteUnits): void
46+
public function handle(): void
4847
{
4948
$now = now();
50-
// Temp Hard Coding of Immune Groups (Config Files To Come)
5149
$current = Carbon::now();
50+
5251
$groups = Group::query()
5352
->where('autogroup', '=', 1)
5453
->orderBy('position')
@@ -64,19 +63,25 @@ public function handle(ByteUnits $byteUnits): void
6463
$seedtime = null;
6564

6665
foreach ($groups as $group) {
66+
$seedtime ??= DB::table('history')
67+
->whereNull('deleted_at')
68+
->where('user_id', '=', $user->id)
69+
->avg('seedtime') ?? 0;
70+
71+
$seedsize ??= $user->seedingTorrents()->sum('size');
72+
6773
if (
6874
//short circuit when the values are 0 or null
69-
($group->min_uploaded ? $group->min_uploaded <= $user->uploaded : true)
70-
&& ($group->min_ratio ? $group->min_ratio <= $user->ratio : true)
71-
&& ($group->min_age ? $user->created_at->addRealSeconds($group->min_age)->isBefore($current) : true)
72-
&& ($group->min_avg_seedtime ? $group->min_avg_seedtime <= ($seedtime ??= DB::table('history')->where('user_id', '=', $user->id)->avg('seedtime') ?? 0) : true)
73-
&& ($group->min_seedsize ? $group->min_seedsize <= ($seedsize ??= $user->seedingTorrents()->sum('size')) : true)
75+
(!$group->min_uploaded || $group->min_uploaded <= $user->uploaded)
76+
&& (!$group->min_ratio || $group->min_ratio <= $user->ratio)
77+
&& (!$group->min_age || $user->created_at->addSeconds($group->min_age)->isBefore($current))
78+
&& (!$group->min_avg_seedtime || $group->min_avg_seedtime <= ($seedtime))
79+
&& (!$group->min_seedsize || $group->min_seedsize <= ($seedsize))
7480
) {
7581
$user->group_id = $group->id;
7682

7783
// Leech ratio dropped below sites minimum
78-
79-
if ($user->group_id == UserGroup::LEECH->value) {
84+
if ($user->group_id === UserGroup::LEECH->value) {
8085
$user->can_request = false;
8186
$user->can_invite = false;
8287
$user->can_download = false;
@@ -96,7 +101,7 @@ public function handle(ByteUnits $byteUnits): void
96101
}
97102
}
98103

99-
$elapsed = now()->floatDiffInSeconds($now);
104+
$elapsed = now()->diffInSeconds($now);
100105
$this->comment('Automated User Group Command Complete ('.$elapsed.')');
101106
}
102107
}

app/Console/Commands/AutoRefundDownload.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ class AutoRefundDownload extends Command
3636

3737
/**
3838
* Execute the console command.
39-
*
40-
* @return mixed
4139
*/
42-
public function handle()
40+
public function handle(): void
4341
{
4442
$now = Carbon::now();
4543
$MIN_SEEDTIME = config('hitrun.seedtime');

app/Http/Controllers/API/TorrentController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ public function store(Request $request): \Illuminate\Http\JsonResponse
167167
$du_until = $request->input('du_until');
168168

169169
if (($user->group->is_modo || $user->group->is_internal) && isset($du_until)) {
170-
$torrent->du_until = Carbon::now()->addDays($request->input('du_until'));
170+
$torrent->du_until = Carbon::now()->addDays($request->integer('du_until'));
171171
}
172172
$torrent->free = $user->group->is_modo || $user->group->is_internal ? ($request->input('free') ?? 0) : 0;
173173
$fl_until = $request->input('fl_until');
174174

175175
if (($user->group->is_modo || $user->group->is_internal) && isset($fl_until)) {
176-
$torrent->fl_until = Carbon::now()->addDays($request->input('fl_until'));
176+
$torrent->fl_until = Carbon::now()->addDays($request->integer('fl_until'));
177177
}
178178
$torrent->sticky = $user->group->is_modo || $user->group->is_internal ? ($request->input('sticky') ?? 0) : 0;
179179
$torrent->moderated_at = Carbon::now();

app/Http/Controllers/Controller.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Illuminate\Foundation\Validation\ValidatesRequests;
1818
use Illuminate\Routing\Controller as BaseController;
1919

20-
class Controller extends BaseController
20+
abstract class Controller extends BaseController
2121
{
2222
use AuthorizesRequests;
2323
use ValidatesRequests;

app/Http/Controllers/TorrentBuffController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function grantFL(Request $request, int $id): \Illuminate\Http\RedirectRes
102102

103103
if ($request->freeleech != 0) {
104104
if ($request->fl_until !== null) {
105-
$torrent->fl_until = Carbon::now()->addDays($request->fl_until);
105+
$torrent->fl_until = Carbon::now()->addDays($request->integer('fl_until'));
106106
$this->chatRepository->systemMessage(
107107
sprintf('Ladies and Gents, [url=%s]%s[/url] has been granted %s%% FreeLeech for '.$request->fl_until.' days.', $torrentUrl, $torrent->name, $request->freeleech)
108108
);
@@ -212,7 +212,7 @@ public function grantDoubleUp(Request $request, int $id): \Illuminate\Http\Redir
212212
$du_until = $request->input('du_until');
213213

214214
if ($du_until !== null) {
215-
$torrent->du_until = Carbon::now()->addDays($request->input('du_until'));
215+
$torrent->du_until = Carbon::now()->addDays($request->integer('du_until'));
216216
$this->chatRepository->systemMessage(
217217
sprintf('Ladies and Gents, [url=%s]%s[/url] has been granted Double Upload for '.$request->input('du_until').' days.', $torrentUrl, $torrent->name)
218218
);

app/Models/Apikey.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ class Apikey extends Model
4141
protected $guarded = ['id'];
4242

4343
/**
44-
* The attributes that should be cast.
44+
* Get the attributes that should be cast.
4545
*
46-
* @var array<string, string>
46+
* @return array<string, string>
4747
*/
48-
protected $casts = [
49-
'deleted_at' => 'datetime',
50-
];
48+
protected function casts(): array
49+
{
50+
return [
51+
'deleted_at' => 'datetime',
52+
];
53+
}
5154

5255
/**
5356
* Belongs to a user.

app/Models/Application.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,17 @@ class Application extends Model
5252
'moderated_at',
5353
];
5454

55-
protected $casts = [
56-
'moderated_at' => 'datetime',
57-
];
55+
/**
56+
* Get the attributes that should be cast.
57+
*
58+
* @return array<string, string>
59+
*/
60+
protected function casts(): array
61+
{
62+
return [
63+
'moderated_at' => 'datetime',
64+
];
65+
}
5866

5967
/**
6068
* The attributes that aren't mass assignable.

app/Models/BonExchange.php

+11-8
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,19 @@ class BonExchange extends Model
4040
public $timestamps = false;
4141

4242
/**
43-
* The Attributes That Should Be Casted To Native Types.
43+
* Get the attributes that should be cast.
4444
*
45-
* @var array<string, string>
45+
* @return array<string, string>
4646
*/
47-
protected $casts = [
48-
'upload' => 'boolean',
49-
'download' => 'boolean',
50-
'personal_freeleech' => 'boolean',
51-
'invite' => 'boolean',
52-
];
47+
protected function casts(): array
48+
{
49+
return [
50+
'upload' => 'boolean',
51+
'download' => 'boolean',
52+
'personal_freeleech' => 'boolean',
53+
'invite' => 'boolean',
54+
];
55+
}
5356

5457
/**
5558
* The attributes that aren't mass assignable.

app/Models/Bot.php

+8-12
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,16 @@ class Bot extends Model
5151
use HasFactory;
5252

5353
/**
54-
* Indicates If The Model Should Be Timestamped.
54+
* Get the attributes that should be cast.
5555
*
56-
* @var bool
56+
* @return array<string, string>
5757
*/
58-
public $timestamps = true;
59-
60-
/**
61-
* The Attributes That Should Be Cast To Native Types.
62-
*
63-
* @var array<string, string>
64-
*/
65-
protected $casts = [
66-
'name' => 'string',
67-
];
58+
protected function casts(): array
59+
{
60+
return [
61+
'name' => 'string',
62+
];
63+
}
6864

6965
/**
7066
* The attributes that aren't mass assignable.

app/Models/BotTransaction.php

-7
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ class BotTransaction extends Model
3636
use Auditable;
3737
use HasFactory;
3838

39-
/**
40-
* Indicates If The Model Should Be Timestamped.
41-
*
42-
* @var bool
43-
*/
44-
public $timestamps = true;
45-
4639
/**
4740
* Belongs To A User.
4841
*

app/Models/Category.php

+11-8
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,19 @@ class Category extends Model
4545
public $timestamps = false;
4646

4747
/**
48-
* The Attributes That Should Be Mutated To Dates.
48+
* Get the attributes that should be cast.
4949
*
50-
* @var array<string, string>
50+
* @return array<string, string>
5151
*/
52-
public $casts = [
53-
'music_meta' => 'boolean',
54-
'game_meta' => 'boolean',
55-
'tv_meta' => 'boolean',
56-
'movie_meta' => 'boolean',
57-
];
52+
protected function casts(): array
53+
{
54+
return [
55+
'music_meta' => 'boolean',
56+
'game_meta' => 'boolean',
57+
'tv_meta' => 'boolean',
58+
'movie_meta' => 'boolean',
59+
];
60+
}
5861

5962
/**
6063
* The attributes that aren't mass assignable.

app/Models/EmailUpdate.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@ class EmailUpdate extends Model
4040
protected $guarded = ['id'];
4141

4242
/**
43-
* The attributes that should be cast.
43+
* Get the attributes that should be cast.
4444
*
45-
* @var array<string, string>
45+
* @return array<string, string>
4646
*/
47-
protected $casts = [
48-
'created_at' => 'datetime',
49-
'deleted_at' => 'datetime',
50-
];
47+
protected function casts(): array
48+
{
49+
return [
50+
'created_at' => 'datetime',
51+
'deleted_at' => 'datetime',
52+
];
53+
}
5154

5255
/**
5356
* Belongs to a user.

app/Models/ForumPermission.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,18 @@ class ForumPermission extends Model
4242
public $guarded = [];
4343

4444
/**
45-
* The attributes that should be cast.
45+
* Get the attributes that should be cast.
4646
*
47-
* @var array<string, string>
47+
* @return array<string, string>
4848
*/
49-
protected $casts = [
50-
'read_topic' => 'boolean',
51-
'reply_topic' => 'boolean',
52-
'start_topic' => 'boolean',
53-
];
49+
protected function casts(): array
50+
{
51+
return [
52+
'read_topic' => 'boolean',
53+
'reply_topic' => 'boolean',
54+
'start_topic' => 'boolean',
55+
];
56+
}
5457

5558
/**
5659
* Belongs To A Group.

app/Models/Gift.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ class Gift extends Model
3232
public $timestamps = false;
3333

3434
/**
35-
* The attributes that should be cast.
35+
* Get the attributes that should be cast.
3636
*
37-
* @var array<string, string>
37+
* @return array<string, string>
3838
*/
39-
protected $casts = [
40-
'created_at' => 'datetime',
41-
];
39+
protected function casts(): array
40+
{
41+
return [
42+
'created_at' => 'datetime',
43+
];
44+
}
4245

4346
/**
4447
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, self>

app/Models/Group.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,16 @@ class Group extends Model
5656
use HasFactory;
5757

5858
/**
59-
* The attributes that should be cast.
59+
* Get the attributes that should be cast.
6060
*
61-
* @var array<string, string>
61+
* @return array<string, string>
6262
*/
63-
protected $casts = [
64-
'system_required' => 'boolean',
65-
];
63+
protected function casts(): array
64+
{
65+
return [
66+
'system_required' => 'boolean',
67+
];
68+
}
6669

6770
/**
6871
* The attributes that aren't mass assignable.

app/Models/History.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,18 @@ class History extends Model
5757
protected $guarded = [];
5858

5959
/**
60-
* The Attributes That Should Be Mutated To Dates.
60+
* Get the attributes that should be cast.
6161
*
62-
* @var array<string, string>
62+
* @return array<string, string>
6363
*/
64-
protected $casts = [
65-
'completed_at' => 'datetime',
66-
'hitrun' => 'boolean',
67-
'prewarn' => 'boolean',
68-
];
64+
protected function casts(): array
65+
{
66+
return [
67+
'completed_at' => 'datetime',
68+
'hitrun' => 'boolean',
69+
'prewarn' => 'boolean',
70+
];
71+
}
6972

7073
/**
7174
* Belongs To A User.

0 commit comments

Comments
 (0)