A lot of things

This commit is contained in:
2026-06-16 16:21:43 +02:00
parent 4f9f6c63b3
commit 7e1e26f20b
126 changed files with 7917 additions and 204 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use App\Helpers\EntryHelpers;
use App\Traits\HasGallery;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -10,6 +11,8 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Monolog\Level;
use Spatie\Activitylog\Models\Concerns\LogsActivity;
use Spatie\Activitylog\Support\LogOptions;
/**
* @property int $id
@@ -22,6 +25,7 @@ use Monolog\Level;
* @property string|null $staff_comment
* @property \Illuminate\Support\Carbon|null $rejected_at
* @property bool $featured
* @property \Illuminate\Support\Carbon|null $featured_at
* @property int|null $game_id
* @property int|null $platform_id
* @property int|null $status_id
@@ -69,6 +73,7 @@ use Monolog\Level;
* @method static Builder<static>|Entry whereDeletedAt($value)
* @method static Builder<static>|Entry whereDescription($value)
* @method static Builder<static>|Entry whereFeatured($value)
* @method static Builder<static>|Entry whereFeaturedAt($value)
* @method static Builder<static>|Entry whereGameId($value)
* @method static Builder<static>|Entry whereId($value)
* @method static Builder<static>|Entry whereLevelId($value)
@@ -90,12 +95,14 @@ use Monolog\Level;
* @method static Builder<static>|Entry whereYoutubeLink($value)
* @method static Builder<static>|Entry withTrashed(bool $withTrashed = true)
* @method static Builder<static>|Entry withoutTrashed()
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Spatie\Activitylog\Models\Activity> $activitiesAsSubject
* @property-read int|null $activities_as_subject_count
* @mixin \Eloquent
*/
class Entry extends Model
{
use SoftDeletes, HasGallery;
use SoftDeletes, HasGallery, LogsActivity;
/**
* @var string[]
@@ -108,6 +115,7 @@ class Entry extends Model
'main_image',
'state',
'featured',
'featured_at',
'game_id',
'platform_id',
'status_id',
@@ -121,7 +129,8 @@ class Entry extends Model
'comments_thread_id',
'staff_comment',
'rejected_at',
'level_id'
'level_id',
'created_at'
];
/**
@@ -131,6 +140,7 @@ class Entry extends Model
'featured' => 'boolean',
'release_date' => 'date',
'rejected_at' => 'datetime',
'featured_at' => 'datetime',
];
public function scopePublished( Builder $query ): Builder {
@@ -197,7 +207,7 @@ class Entry extends Model
return $this->hasMany(EntryHash::class);
}
public function parseStaffCredits(): array {
public function parseStaffCredits(): ?array {
return json_decode( $this->staff_credits ?? "", true );
}
@@ -205,10 +215,17 @@ class Entry extends Model
if( !$this->youtube_link )
return null;
$pattern = '%(?:https?://)?(?:www\.|m\.)?(?:youtu\.be/|youtube(?:-nocookie)?\.com/(?:watch\?.*v=|embed/|v/|shorts/|live/))([\w-]{11})%i';
return EntryHelpers::getYoutubeVideoId( $this->youtube_link );
}
preg_match($pattern, $this->youtube_link, $matches);
return $matches[1] ?? null;
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->useLogName('entry')
->logAll()
->logOnlyDirty()
->dontLogEmptyChanges()
->setDescriptionForEvent(fn(string $eventName) => "Entry {$eventName}");
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
/**
* @property int $id
@@ -36,6 +37,9 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryFile whereSecondaryOnlinePatcher($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryFile whereState($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryFile whereUpdatedAt($value)
* @property-read \App\Models\PlayOnlineSetting|null $playOnlineSetting
* @property int $download_count
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryFile whereDownloadCount($value)
* @mixin \Eloquent
*/
class EntryFile extends Model
@@ -53,4 +57,15 @@ class EntryFile extends Model
return $this->belongsTo(Entry::class);
}
public function playOnlineSetting(): HasOne
{
return $this->hasOne(PlayOnlineSetting::class,'file_id');
}
public function increaseDownloadCount(): void
{
$this->download_count++;
$this->save();
}
}

View File

@@ -4,5 +4,24 @@ namespace App\Models;
/**
* @deprecated Use Gallery instead.
* @property int $id
* @property string $galleryable_type
* @property int $galleryable_id
* @property string $image
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $galleryable
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryGallery newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryGallery newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryGallery query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryGallery whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryGallery whereGalleryableId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryGallery whereGalleryableType($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryGallery whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryGallery whereImage($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryGallery whereUpdatedAt($value)
* @property int $order
* @method static \Illuminate\Database\Eloquent\Builder<static>|EntryGallery whereOrder($value)
* @mixin \Eloquent
*/
class EntryGallery extends Gallery {}

View File

@@ -19,6 +19,13 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
* @method static \Illuminate\Database\Eloquent\Builder<static>|Gallery whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Gallery whereImage($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Gallery whereUpdatedAt($value)
* @property string $galleryable_type
* @property int $galleryable_id
* @property-read Model|\Eloquent $galleryable
* @method static \Illuminate\Database\Eloquent\Builder<static>|Gallery whereGalleryableId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Gallery whereGalleryableType($value)
* @property int $order
* @method static \Illuminate\Database\Eloquent\Builder<static>|Gallery whereOrder($value)
* @mixin \Eloquent
*/
class Gallery extends Model

129
app/Models/LogXfUser.php Normal file
View File

@@ -0,0 +1,129 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Used only for logging details on XenForo user.
*
* Read-Only, must not be used in other things than logging.
*
* @property int $user_id
* @property string $username
* @property int $username_date
* @property int $username_date_visible
* @property string $email
* @property string $custom_title
* @property int $language_id
* @property int $style_id 0 = use system default
* @property string $style_variation
* @property string $timezone Example: 'Europe/London'
* @property int $visible Show browsing activity to others
* @property int $activity_visible
* @property int $user_group_id
* @property string $secondary_group_ids
* @property int $display_style_group_id User group ID that provides user styling
* @property int $permission_combination_id
* @property int $message_count
* @property int $question_solution_count
* @property int $conversations_unread
* @property int $register_date
* @property int $last_activity
* @property int|null $last_summary_email_date
* @property int $trophy_points
* @property int $alerts_unviewed
* @property int $alerts_unread
* @property int $avatar_date
* @property int $avatar_width
* @property int $avatar_height
* @property int $avatar_highdpi
* @property int $avatar_optimized
* @property string $gravatar If specified, this is an email address corresponding to the user's 'Gravatar'
* @property string $user_state
* @property string $security_lock
* @property int $is_moderator
* @property int $is_admin
* @property int $is_banned
* @property int $reaction_score
* @property int $vote_score
* @property int $warning_points
* @property int $is_staff
* @property string $secret_key
* @property int $privacy_policy_accepted
* @property int $terms_accepted
* @property int $rhpz_entry_count
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereActivityVisible($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereAlertsUnread($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereAlertsUnviewed($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereAvatarDate($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereAvatarHeight($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereAvatarHighdpi($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereAvatarOptimized($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereAvatarWidth($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereConversationsUnread($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereCustomTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereDisplayStyleGroupId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereGravatar($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereIsAdmin($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereIsBanned($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereIsModerator($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereIsStaff($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereLanguageId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereLastActivity($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereLastSummaryEmailDate($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereMessageCount($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser wherePermissionCombinationId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser wherePrivacyPolicyAccepted($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereQuestionSolutionCount($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereReactionScore($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereRegisterDate($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereRhpzEntryCount($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereSecondaryGroupIds($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereSecretKey($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereSecurityLock($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereStyleId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereStyleVariation($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereTermsAccepted($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereTimezone($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereTrophyPoints($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereUserGroupId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereUserState($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereUsername($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereUsernameDate($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereUsernameDateVisible($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereVisible($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereVoteScore($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|LogXfUser whereWarningPoints($value)
* @mixin \Eloquent
*/
class LogXfUser extends Model
{
protected $connection = 'xenforo';
protected $table = 'user';
protected $primaryKey = 'user_id';
public $timestamps = false;
public $incrementing = true;
public function save(array $options = [])
{
return false;
}
public function delete()
{
return false;
}
public function update(array $attributes = [], array $options = [])
{
return false;
}
}

118
app/Models/News.php Normal file
View File

@@ -0,0 +1,118 @@
<?php
namespace App\Models;
use App\Helpers\EntryHelpers;
use App\Traits\HasGallery;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* @property int $id
* @property string $title
* @property string $slug
* @property int|null $category_id
* @property string $description
* @property string $state
* @property string|null $staff_comment
* @property \Illuminate\Support\Carbon|null $rejected_at
* @property int|null $entry_id
* @property string|null $relevant_link
* @property string|null $youtube_link
* @property int $user_id
* @property int|null $comments_thread_id
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Category|null $category
* @property-read \App\Models\Entry|null $entry
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Gallery> $gallery
* @property-read int|null $gallery_count
* @method static Builder<static>|News inQueue(int $daysRejected = 7)
* @method static Builder<static>|News newModelQuery()
* @method static Builder<static>|News newQuery()
* @method static Builder<static>|News onlyTrashed()
* @method static Builder<static>|News published()
* @method static Builder<static>|News query()
* @method static Builder<static>|News whereCategoryId($value)
* @method static Builder<static>|News whereCommentsThreadId($value)
* @method static Builder<static>|News whereCreatedAt($value)
* @method static Builder<static>|News whereDeletedAt($value)
* @method static Builder<static>|News whereDescription($value)
* @method static Builder<static>|News whereEntryId($value)
* @method static Builder<static>|News whereId($value)
* @method static Builder<static>|News whereRejectedAt($value)
* @method static Builder<static>|News whereRelevantLink($value)
* @method static Builder<static>|News whereSlug($value)
* @method static Builder<static>|News whereStaffComment($value)
* @method static Builder<static>|News whereState($value)
* @method static Builder<static>|News whereTitle($value)
* @method static Builder<static>|News whereUpdatedAt($value)
* @method static Builder<static>|News whereUserId($value)
* @method static Builder<static>|News whereYoutubeLink($value)
* @method static Builder<static>|News withTrashed(bool $withTrashed = true)
* @method static Builder<static>|News withoutTrashed()
* @mixin \Eloquent
*/
class News extends Model
{
use SoftDeletes, HasGallery;
protected $table = 'news';
protected $fillable = [
'title',
'slug',
'description',
'state',
'category_id',
'entry_id',
'relevant_link',
'youtube_link',
'user_id',
'comments_thread_id',
'staff_comment',
'rejected_at',
'created_at'
];
protected $casts = [
'rejected_at' => 'datetime',
];
public function scopePublished(Builder $query): Builder
{
return $query->where('state', 'published' );
}
public function scopeInQueue( Builder $query, int $daysRejected = 7 ): Builder
{
return $query->withTrashed()->where(function($q) use($daysRejected) {
$q->where('state', 'pending')->whereNull('deleted_at');
})->orWhere(function($q) use($daysRejected) {
$q->where('state', 'rejected')->whereNotNull('rejected_at')->where('rejected_at', '>=', now()->subDays($daysRejected) );
});
}
public function entry(): BelongsTo
{
return $this->belongsTo(Entry::class);
}
public function category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
public function getYoutubeVideoId(): ?string {
if( !$this->youtube_link )
return null;
return EntryHelpers::getYoutubeVideoId( $this->youtube_link );
}
}

View File

@@ -25,6 +25,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
* @method static \Illuminate\Database\Eloquent\Builder<static>|Platform whereShortName($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Platform whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Platform whereUpdatedAt($value)
* @property string|null $play_online_core
* @method static \Illuminate\Database\Eloquent\Builder<static>|Platform wherePlayOnlineCore($value)
* @mixin \Eloquent
*/
class Platform extends Model

View File

@@ -0,0 +1,45 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property int $file_id
* @property string $core
* @property bool $threads
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\EntryFile $file
* @method static \Illuminate\Database\Eloquent\Builder<static>|PlayOnlineSetting newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|PlayOnlineSetting newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|PlayOnlineSetting query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|PlayOnlineSetting whereCore($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PlayOnlineSetting whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PlayOnlineSetting whereFileId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PlayOnlineSetting whereThreads($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PlayOnlineSetting whereUpdatedAt($value)
* @mixin \Eloquent
*/
class PlayOnlineSetting extends Model
{
protected $primaryKey = 'file_id';
public $incrementing = false;
protected $keyType = 'int';
protected $fillable = [
'file_id',
'core',
'threads'
];
protected $casts = [
'threads' => 'boolean',
];
public function file(): BelongsTo
{
return $this->belongsTo(EntryFile::class, 'file_id');
}
}