Initial commit

This commit is contained in:
root
2026-05-09 17:28:23 +02:00
commit 9d73f82529
5575 changed files with 281989 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace App\Models\Miscellaneous;
use Illuminate\Database\Eloquent\Model;
class AlertLog extends Model
{
#[\Override]
protected $fillable = [
'type',
'severity',
'message',
'context',
'sent_via_email',
'sent_via_discord',
'is_read',
'read_at',
];
#[\Override]
protected $casts = [
'context' => 'array',
'sent_via_email' => 'boolean',
'sent_via_discord' => 'boolean',
'is_read' => 'boolean',
'read_at' => 'datetime',
];
public function markAsRead(): void
{
$this->update([
'is_read' => true,
'read_at' => now(),
]);
}
public function scopeUnread($query)
{
return $query->where('is_read', false);
}
public function scopeByType($query, string $type)
{
return $query->where('type', $type);
}
public function scopeBySeverity($query, string $severity)
{
return $query->where('severity', $severity);
}
public function scopeCritical($query)
{
return $query->where('severity', 'critical');
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Models\Miscellaneous;
use App\Models\Concerns\BelongsToUser;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class CameraLike extends Model
{
use BelongsToUser;
#[\Override]
protected $guarded = ['id', 'created_at', 'updated_at', 'user_id', 'photo_id'];
#[\Override]
public $timestamps = false;
#[\Override]
protected $table = 'camera_likes';
public function cameraWeb(): BelongsTo
{
return $this->belongsTo(CameraWeb::class, 'camera_id');
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Models\Miscellaneous;
use App\Models\Concerns\BelongsToUser;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class CameraView extends Model
{
use BelongsToUser;
#[\Override]
protected $guarded = ['id', 'created_at', 'updated_at', 'user_id', 'photo_id'];
#[\Override]
public $timestamps = false;
#[\Override]
protected $table = 'camera_views';
public function cameraWeb(): BelongsTo
{
return $this->belongsTo(CameraWeb::class, 'camera_id');
}
}
+93
View File
@@ -0,0 +1,93 @@
<?php
namespace App\Models\Miscellaneous;
use App\Models\Concerns\BelongsToUser;
use App\Models\Room;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* @property int $id
* @property int $user_id
* @property int|null $room_id
* @property string $url
* @property string $caption
* @property int $timestamp
* @property int $likes
* @property int $views
* @property-read Carbon $timestamp
* @property-read string $formattedDate
* @property-read User|null $user
* @property-read Room|null $room
* @property-read Collection<int, CameraLike> $likesRelation
* @property-read Collection<int, CameraView> $views
*
* @method static \Illuminate\Database\Eloquent\Builder<static>|CameraWeb where($column, $operator = null, $value = null)
* @method static \Illuminate\Database\Eloquent\Builder<static>|CameraWeb latest($column = 'created_at')
* @method static \Illuminate\Database\Eloquent\Builder<static>|CameraWeb count($columns = '*')
* @method static \Illuminate\Database\Eloquent\Builder<static>|CameraWeb take(int $value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|CameraWeb with($relations)
*/
class CameraWeb extends Model
{
use BelongsToUser;
#[\Override]
protected $table = 'camera_web';
#[\Override]
protected $guarded = ['id', 'created_at', 'updated_at', 'user_id', 'image', 'caption'];
#[\Override]
public $timestamps = false;
/** @var array<string, string> */
#[\Override]
protected $casts = [
'timestamp' => 'datetime',
];
public function scopePeriod(Builder $query, $period): void
{
if ($period == 'today') {
$query->where('timestamp', '>=', Carbon::today()->timestamp);
}
if ($period == 'last_week') {
$query->whereBetween('timestamp', [now()->subWeek()->timestamp, now()->timestamp]);
}
if ($period == 'last_month') {
$query->whereBetween('timestamp', [now()->subMonth()->timestamp, now()->timestamp]);
}
}
public function room(): BelongsTo
{
return $this->belongsTo(Room::class);
}
public function likes(): HasMany
{
return $this->hasMany(CameraLike::class);
}
public function views(): HasMany
{
return $this->hasMany(CameraView::class);
}
public function formattedDate(): Attribute
{
return new Attribute(
get: fn () => Carbon::parse($this->timestamp)->format('Y-m-d H:i'),
);
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace App\Models\Miscellaneous;
use App\Models\Concerns\BelongsToUser;
use Illuminate\Database\Eloquent\Model;
/**
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteBetaCode where($column, $operator = null, $value = null)
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteBetaCode whereCode($code)
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteBetaCode whereNull($columns, $boolean = 'and', $not = false)
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteBetaCode doesntExist()
*/
class WebsiteBetaCode extends Model
{
use BelongsToUser;
#[\Override]
protected $guarded = ['id', 'created_at', 'updated_at', 'code', 'user_id'];
}
+16
View File
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace App\Models\Miscellaneous;
use Illuminate\Database\Eloquent\Model;
class WebsiteBlockedCountry extends Model
{
#[\Override]
protected $table = 'website_blocked_countries';
#[\Override]
protected $guarded = ['id', 'created_at', 'updated_at', 'country_code'];
}
+22
View File
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace App\Models\Miscellaneous;
use Illuminate\Database\Eloquent\Model;
/**
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteInstallation first($columns = ['*'])
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteInstallation latest($column = 'created_at')
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteInstallation create($attributes = [])
* @method static mixed toArray()
*/
class WebsiteInstallation extends Model
{
#[\Override]
protected $table = 'website_installation';
#[\Override]
protected $guarded = ['id', 'created_at', 'updated_at'];
}
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Models\Miscellaneous;
use Illuminate\Database\Eloquent\Model;
/**
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteIpBlacklist where($column, $operator = null, $value = null)
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteIpBlacklist create($attributes = [])
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteIpBlacklist exists()
*/
class WebsiteIpBlacklist extends Model
{
#[\Override]
protected $table = 'website_ip_blacklist';
#[\Override]
protected $guarded = ['id', 'created_at', 'updated_at', 'ip_address', 'reason'];
}
+20
View File
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace App\Models\Miscellaneous;
use Illuminate\Database\Eloquent\Model;
/**
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteIpWhitelist where($column, $operator = null, $value = null)
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteIpWhitelist exists()
*/
class WebsiteIpWhitelist extends Model
{
#[\Override]
protected $table = 'website_ip_whitelist';
#[\Override]
protected $guarded = ['id', 'created_at', 'updated_at', 'ip_address'];
}
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Models\Miscellaneous;
use Illuminate\Database\Eloquent\Model;
/**
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteLanguage where($column, $operator = null, $value = null)
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteLanguage exists()
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteLanguage doesntExist()
*/
class WebsiteLanguage extends Model
{
#[\Override]
protected $guarded = ['id', 'created_at', 'updated_at', 'code', 'name'];
#[\Override]
public $timestamps = false;
}
+16
View File
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace App\Models\Miscellaneous;
use App\Models\Concerns\BelongsToUser;
use Illuminate\Database\Eloquent\Model;
class WebsiteMaintenanceTask extends Model
{
use BelongsToUser;
#[\Override]
protected $guarded = ['id', 'user_id', 'created_at', 'updated_at'];
}
+29
View File
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace App\Models\Miscellaneous;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class WebsitePermission extends Model
{
/**
* Zorgt ervoor dat alle velden behalve ID gevuld mogen worden.
*/
#[\Override]
protected $guarded = ['id', 'created_at', 'updated_at', 'permission', 'rank_id'];
/**
* Automatische cache-opschoning bij wijzigingen.
*/
#[\Override]
protected static function booted(): void
{
$clearCache = fn () => Cache::forget('website_permissions');
static::saved($clearCache);
static::deleted($clearCache);
}
}
+129
View File
@@ -0,0 +1,129 @@
<?php
namespace App\Models\Miscellaneous;
use App\Services\CacheService;
use App\Services\SettingsService;
use Database\Factories\Miscellaneous\WebsiteSettingFactory;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteSetting where($column, $operator = null, $value = null)
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteSetting whereIn(string $column, array $values)
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteSetting whereNotIn(string $column, array $values)
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteSetting orWhere($column, $operator = null, $value = null)
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteSetting count($columns = '*')
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteSetting get($columns = ['*'])
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteSetting first()
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteSetting updateOrCreate(array $attributes, array $values = [])
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteSetting pluck($column, $key = null)
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteSetting exists()
*
* @property string $key
* @property string|null $value
*/
class WebsiteSetting extends Model
{
use HasFactory;
protected static function newFactory()
{
return WebsiteSettingFactory::new();
}
#[\Override]
protected $guarded = ['id'];
public static function updateOrCreate(array $attributes, array $values = []): Builder|Model
{
$instance = static::firstOrNew($attributes);
if (! $instance->getKey()) {
$instance->forceFill(array_merge($attributes, $values))->save();
} else {
$instance->fill($values)->save();
}
return $instance;
}
public static function firstOrCreate(array $attributes, array $values = []): Model|static
{
$instance = static::firstOrNew($attributes);
if (! $instance->getKey()) {
$instance->forceFill(array_merge($attributes, $values))->save();
}
return $instance;
}
#[\Override]
public $timestamps = false;
#[\Override]
protected static function booted(): void
{
static::saved(function (WebsiteSetting $setting) {
SettingsService::clearCache();
self::clearRelatedCache($setting->key);
});
static::deleted(function (WebsiteSetting $setting) {
SettingsService::clearCache();
self::clearRelatedCache($setting->key);
});
}
private static function clearRelatedCache(?string $key): void
{
if ($key === null) {
CacheService::clearAllAppCache();
return;
}
if (str_starts_with($key, 'points_')) {
CacheService::clearPointsSettings();
CacheService::clearLeaderboards();
CacheService::clearApiCache();
return;
}
if (str_starts_with($key, 'ai_filter_') || str_starts_with($key, 'filter_word_')) {
CacheService::clearContentModeration();
return;
}
if (str_starts_with($key, 'radio_')) {
CacheService::clearRadioSettings();
CacheService::clearLeaderboards();
CacheService::clearApiCache();
CacheService::clearLeaderboard();
return;
}
if (str_starts_with($key, 'rare_value_')) {
CacheService::clearRareValueCategories();
return;
}
if (str_starts_with($key, 'staff_')) {
CacheService::clearStaff();
CacheService::clearLeaderboard();
return;
}
if (str_starts_with($key, 'help_center') || str_starts_with($key, 'website_rules')) {
CacheService::clearHelpCenter();
return;
}
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Models\Miscellaneous;
use Illuminate\Database\Eloquent\Model;
/**
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteWordfilter get($columns = ['*'])
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteWordfilter pluck($column, $key = null)
* @method static mixed toArray()
*/
class WebsiteWordfilter extends Model
{
#[\Override]
protected $table = 'website_wordfilter';
#[\Override]
protected $guarded = ['id', 'created_at', 'updated_at', 'word', 'replacement'];
}