🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 20:43:46 +01:00
parent deed2158ca
commit 7b9849c159
77 changed files with 1084 additions and 13612 deletions
@@ -5,6 +5,8 @@ namespace App\Models\Community\Staff;
use App\Models\Game\Permission;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class WebsiteOpenPosition extends Model
{
@@ -12,7 +14,7 @@ class WebsiteOpenPosition extends Model
protected $table = 'website_open_positions';
use HasFactory;
// use HasFactory;
protected $fillable = [
'permission_id',
@@ -25,21 +27,31 @@ class WebsiteOpenPosition extends Model
protected static function boot()
{
parent::boot();
static::deleting(function ($openPosition): void {
static::deleting(function (WebsiteOpenPosition $openPosition): void {
WebsiteStaffApplications::where('rank_id', $openPosition->permission_id)->delete();
});
}
public function permission()
/**
* @return BelongsTo<Permission, $this>
*/
public function permission(): BelongsTo
{
return $this->belongsTo(Permission::class, 'permission_id', 'id');
}
public function applications()
/**
* @return HasMany<WebsiteStaffApplications, $this>
*/
public function applications(): HasMany
{
return $this->hasMany(WebsiteStaffApplications::class, 'rank_id', 'permission_id');
}
/**
* @param \Illuminate\Database\Eloquent\Builder<WebsiteOpenPosition> $query
* @return \Illuminate\Database\Eloquent\Builder<WebsiteOpenPosition>
*/
#[\Illuminate\Database\Eloquent\Attributes\Scope]
protected function canApply($query)
{
+8
View File
@@ -4,6 +4,14 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property string $id
* @property int|null $user_id
* @property string|null $ip_address
* @property string|null $user_agent
* @property string $payload
* @property int $last_activity
*/
class Session extends Model
{
protected $guarded = ['id'];
@@ -8,6 +8,13 @@ class WebsiteShopVoucher extends Model
{
protected $guarded = ['id'];
/**
* @var array<string, string>
*/
protected $casts = [
'expires_at' => 'datetime',
];
protected function casts(): array
{
return [
+17 -7
View File
@@ -66,6 +66,7 @@ use Spatie\Activitylog\Traits\LogsActivity;
* @property \Illuminate\Support\Carbon|null $two_factor_confirmed_at
* @property string|null $remember_token
* @property \Illuminate\Support\Carbon|null $email_verified_at
* @property int $website_balance
*/
class User extends Authenticatable implements FilamentUser, HasName
{
@@ -260,23 +261,32 @@ class User extends Authenticatable implements FilamentUser, HasName
}
/**
* @return \Illuminate\Database\Eloquent\Collection<int, MessengerFriendship>
* @return \Illuminate\Database\Eloquent\Collection<int, \App\Models\Game\Player\MessengerFriendship>
*/
public function getOnlineFriends(int $total = 10): \Illuminate\Database\Eloquent\Collection
{
return $this->friends()
/** @var \Illuminate\Database\Eloquent\Collection<int, \App\Models\Game\Player\MessengerFriendship> $friends */
$friends = $this->friends()
->select(['user_two_id', 'users.id', 'users.username', 'users.look', 'users.motto', 'users.last_online'])
->join('users', 'users.id', '=', 'user_two_id')
->where('users.online', '1')
->inRandomOrder()
->limit($total)
->get();
return $friends;
}
public function confirmTwoFactorAuthentication(string $code): void
public function confirmTwoFactorAuthentication(string $code): bool
{
$secret = $this->two_factor_secret;
if (! is_string($secret)) {
return false;
}
$codeIsValid = app(TwoFactorAuthenticationProvider::class)
->verify(decrypt($this->two_factor_secret), $code);
->verify(decrypt($secret), $code);
if (! $codeIsValid) {
return false;
@@ -289,12 +299,12 @@ class User extends Authenticatable implements FilamentUser, HasName
return true;
}
public function hasAppliedForPosition(int $rankId)
public function hasAppliedForPosition(int $rankId): bool
{
return $this->applications()->where('rank_id', '=', $rankId)->exists();
}
public function changePassword(string $newPassword)
public function changePassword(string $newPassword): void
{
$this->password = Hash::make($newPassword);
$this->save();
@@ -307,7 +317,7 @@ class User extends Authenticatable implements FilamentUser, HasName
public function canAccessPanel(Panel $panel): bool
{
return hasHousekeepingPermission('can_access_housekeeping');
return (bool) hasHousekeepingPermission('can_access_housekeeping');
}
public function getActivitylogOptions(): LogOptions
+6
View File
@@ -16,11 +16,17 @@ class Ban extends Model
public $timestamps = false;
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @return BelongsTo<User, $this>
*/
public function staff(): BelongsTo
{
return $this->belongsTo(User::class, 'user_staff_id');
@@ -10,6 +10,9 @@ class ClaimedReferralLog extends Model
{
protected $guarded = ['id'];
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
@@ -6,10 +6,20 @@ use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property int $id
* @property int $user_id
* @property int $referrals_total
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
*/
class UserReferral extends Model
{
protected $guarded = ['id'];
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
@@ -10,11 +10,17 @@ class WebsiteUserGuestbook extends Model
{
protected $guarded = ['id'];
/**
* @return BelongsTo<User, $this>
*/
public function profile(): BelongsTo
{
return $this->belongsTo(User::class, 'profile_id');
}
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
+13 -7
View File
@@ -4,35 +4,41 @@ namespace App\Models;
use App\Services\SettingsService;
use Exception;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage;
/**
* @property string $image
*/
class WebsiteAd extends Model
{
use HasFactory;
protected $fillable = [
'image',
];
/**
* @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
*/
protected function imageUrl(): \Illuminate\Database\Eloquent\Casts\Attribute
{
return \Illuminate\Database\Eloquent\Casts\Attribute::make(get: function () {
$settingsService = app(SettingsService::class);
/** @var string $adsPicturePath */
$adsPicturePath = Cache::remember('ads_picture_path', 3600, fn () => $settingsService->getOrDefault('ads_picture_path'));
if (! str_starts_with((string) $adsPicturePath, 'http')) {
$adsPicturePath = rtrim((string) config('app.url'), '/') . '/' . ltrim((string) $adsPicturePath, '/');
if (! str_starts_with($adsPicturePath, 'http')) {
$adsPicturePath = rtrim((string) config('app.url'), '/') . '/' . ltrim($adsPicturePath, '/');
}
return rtrim((string) $adsPicturePath, '/') . '/' . $this->image;
return rtrim($adsPicturePath, '/') . '/' . $this->image;
});
}
#[\Override]
protected static function booted()
{
static::deleting(function ($websiteAd): void {
static::deleting(function (WebsiteAd $websiteAd): void {
try {
$websiteAd->configureAdsDisk();
-3
View File
@@ -2,13 +2,10 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class WebsiteBadge extends Model
{
use HasFactory;
protected $fillable = [
'badge_key',
'badge_name',
+5 -1
View File
@@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class WebsiteDrawBadge extends Model
{
@@ -10,7 +11,10 @@ class WebsiteDrawBadge extends Model
protected $guarded = ['id'];
public function user()
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
-2
View File
@@ -2,14 +2,12 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
class Wordfilter extends Model
{
use HasFactory;
use LogsActivity;
protected $guarded = [];