|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Models; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
6
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo; |
|
7
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany; |
|
8
|
|
|
use Laravel\Scout\Searchable; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* App\Models\GamesInfo. |
|
12
|
|
|
* |
|
13
|
|
|
* @property int $id |
|
14
|
|
|
* @property string $title |
|
15
|
|
|
* @property string|null $asin |
|
16
|
|
|
* @property string|null $url |
|
17
|
|
|
* @property string|null $publisher |
|
18
|
|
|
* @property int|null $genres_id |
|
19
|
|
|
* @property string|null $esrb |
|
20
|
|
|
* @property string|null $releasedate |
|
21
|
|
|
* @property string|null $review |
|
22
|
|
|
* @property bool $cover |
|
23
|
|
|
* @property bool $backdrop |
|
24
|
|
|
* @property string $trailer |
|
25
|
|
|
* @property string $classused |
|
26
|
|
|
* @property \Carbon\Carbon|null $created_at |
|
27
|
|
|
* @property \Carbon\Carbon|null $updated_at |
|
28
|
|
|
* |
|
29
|
|
|
* @property-read Genre|null $genre |
|
30
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|Release[] $releases |
|
31
|
|
|
* |
|
32
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereAsin($value) |
|
33
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereBackdrop($value) |
|
34
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereClassused($value) |
|
35
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereCover($value) |
|
36
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereCreatedAt($value) |
|
37
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereEsrb($value) |
|
38
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereGenresId($value) |
|
39
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereId($value) |
|
40
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo wherePublisher($value) |
|
41
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereReleasedate($value) |
|
42
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereReview($value) |
|
43
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereTitle($value) |
|
44
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereTrailer($value) |
|
45
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereUpdatedAt($value) |
|
46
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo whereUrl($value) |
|
47
|
|
|
* |
|
48
|
|
|
* @mixin \Eloquent |
|
49
|
|
|
* |
|
50
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo newModelQuery() |
|
51
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo newQuery() |
|
52
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GamesInfo query() |
|
53
|
|
|
*/ |
|
54
|
|
|
class GamesInfo extends Model |
|
55
|
|
|
{ |
|
56
|
|
|
use Searchable; |
|
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @var string |
|
60
|
|
|
*/ |
|
61
|
|
|
protected $table = 'gamesinfo'; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @var bool |
|
65
|
|
|
*/ |
|
66
|
|
|
protected $dateFormat = false; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @var array |
|
70
|
|
|
*/ |
|
71
|
|
|
protected $guarded = []; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @var array |
|
75
|
|
|
*/ |
|
76
|
|
|
protected $casts = [ |
|
77
|
|
|
'cover' => 'boolean', |
|
78
|
|
|
'backdrop' => 'boolean', |
|
79
|
|
|
'genres_id' => 'integer', |
|
80
|
|
|
'releasedate' => 'date', |
|
81
|
|
|
]; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Get the genre for this game. |
|
85
|
|
|
*/ |
|
86
|
|
|
public function genre(): BelongsTo |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->belongsTo(Genre::class, 'genres_id'); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Get the releases for this game. |
|
93
|
|
|
*/ |
|
94
|
|
|
public function releases(): HasMany |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->hasMany(Release::class, 'gamesinfo_id'); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function searchableAs(): string |
|
100
|
|
|
{ |
|
101
|
|
|
return 'ix_title_ft'; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function toSearchableArray(): array |
|
105
|
|
|
{ |
|
106
|
|
|
return [ |
|
107
|
|
|
'title' => $this->title, |
|
108
|
|
|
]; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Get the cover image path. |
|
113
|
|
|
*/ |
|
114
|
|
|
public function getCoverPath(): ?string |
|
115
|
|
|
{ |
|
116
|
|
|
if (!$this->cover) { |
|
117
|
|
|
return null; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
$path = config('nntmux_settings.covers_path') . '/games/' . $this->id . '.jpg'; |
|
121
|
|
|
return file_exists($path) ? $path : null; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Get the backdrop image path. |
|
126
|
|
|
*/ |
|
127
|
|
|
public function getBackdropPath(): ?string |
|
128
|
|
|
{ |
|
129
|
|
|
if (!$this->backdrop) { |
|
130
|
|
|
return null; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
$path = config('nntmux_settings.covers_path') . '/games/' . $this->id . '-backdrop.jpg'; |
|
134
|
|
|
return file_exists($path) ? $path : null; |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
|