-
Notifications
You must be signed in to change notification settings - Fork 400
/
Copy pathHistory.php
108 lines (97 loc) · 3.1 KB
/
History.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
declare(strict_types=1);
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use DateTimeInterface;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\History.
*
* @property int $user_id
* @property int $torrent_id
* @property string $agent
* @property int $uploaded
* @property int $actual_uploaded
* @property int $client_uploaded
* @property int $downloaded
* @property int $refunded_download
* @property int $actual_downloaded
* @property int $client_downloaded
* @property int $seeder
* @property int $active
* @property int $seedtime
* @property int $immune
* @property bool $hitrun
* @property \Illuminate\Support\Carbon|null $prewarned_at
*/
class History extends Model
{
/** @use HasFactory<\Database\Factories\HistoryFactory> */
use HasFactory;
use SoftDeletes;
/**
* The Database Table Used By The Model.
*
* @var string
*/
protected $table = 'history';
/**
* The Attributes That Are Mass Assignable.
*
* @var string[]
*/
protected $guarded = [];
/**
* Get the attributes that should be cast.
*
* @return array{completed_at: 'datetime', hitrun: 'bool', prewarned_at: 'datetime'}
*/
protected function casts(): array
{
return [
'completed_at' => 'datetime',
'hitrun' => 'bool',
'prewarned_at' => 'datetime',
];
}
/**
* Belongs To A User.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
*/
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(User::class)->withDefault([
'username' => 'System',
'id' => User::SYSTEM_USER_ID,
]);
}
/**
* Belongs To A Torrent.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Torrent, $this>
*/
public function torrent(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Torrent::class);
}
/**
* Prepare a date for array / JSON serialization.
*/
protected function serializeDate(DateTimeInterface $date): string
{
return $date->format('Y-m-d H:i:s');
}
}