🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 20:59:00 +01:00
parent f2ba190a47
commit 6c42ec0edd
10 changed files with 33 additions and 8 deletions
@@ -8,6 +8,9 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
class MessengerFriendship extends Model
{
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_two_id', 'id');
@@ -16,6 +16,9 @@ class UserBadge extends Model
public $timestamps = false;
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'id');
@@ -16,6 +16,9 @@ class UserCurrency extends Model
public $timestamps = false;
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id', 'id');
@@ -14,6 +14,9 @@ class UserSetting extends Model
public $timestamps = false;
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
@@ -12,6 +12,9 @@ class UserSubscription extends Model
public $timestamps = false;
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
+6
View File
@@ -12,11 +12,17 @@ class Room extends Model
{
protected $guarded = ['id'];
/**
* @return HasOne<Guild, $this>
*/
public function guild(): HasOne
{
return $this->hasOne(Guild::class, 'room_id');
}
/**
* @return BelongsTo<User, $this>
*/
public function owner(): BelongsTo
{
return $this->belongsTo(User::class, 'owner_id', 'id');
@@ -39,22 +39,22 @@ class WebsiteHelpCenterTicket extends Model
return $this->hasMany(WebsiteHelpCenterTicketReply::class, 'ticket_id');
}
public function canDeleteTicket()
public function canDeleteTicket(): bool
{
return $this->user_id === Auth::id() || hasPermission('delete_website_tickets');
}
public function canManageTicket()
public function canManageTicket(): bool
{
return $this->user_id === Auth::id() || hasPermission('manage_website_tickets');
}
public function canCloseTicket()
public function canCloseTicket(): bool
{
return $this->user_id === Auth::id() || hasPermission('manage_website_tickets');
}
public function isOpen()
public function isOpen(): bool
{
return $this->open || hasPermission('manage_website_tickets');
}
@@ -64,6 +64,6 @@ class WebsiteHelpCenterTicket extends Model
*/
protected function content(): \Illuminate\Database\Eloquent\Casts\Attribute
{
return \Illuminate\Database\Eloquent\Casts\Attribute::make(get: fn ($value) => Purify::clean((string) $value));
return \Illuminate\Database\Eloquent\Casts\Attribute::make(get: fn ($value) => Purify::clean(is_string($value) ? $value : ''));
}
}
@@ -22,7 +22,7 @@ class WebsiteHelpCenterTicketReply extends Model
return $this->belongsTo(User::class, 'user_id');
}
public function canDeleteReply()
public function canDeleteReply(): bool
{
return $this->user_id === Auth::id() || hasPermission('delete_website_ticket_replies');
}
@@ -32,6 +32,6 @@ class WebsiteHelpCenterTicketReply extends Model
*/
protected function content(): \Illuminate\Database\Eloquent\Casts\Attribute
{
return \Illuminate\Database\Eloquent\Casts\Attribute::make(get: fn ($value) => Purify::clean((string) $value));
return \Illuminate\Database\Eloquent\Casts\Attribute::make(get: fn ($value) => Purify::clean(is_string($value) ? $value : ''));
}
}
@@ -19,8 +19,11 @@ class CameraWeb extends Model
public $timestamps = false;
/**
* @param Builder<CameraWeb> $query
*/
#[\Illuminate\Database\Eloquent\Attributes\Scope]
protected function period(Builder $query, $period): void
protected function period(Builder $query, string $period): void
{
if ($period == 'today') {
$query->where('timestamp', '>=', \Illuminate\Support\Facades\Date::today()->timestamp);
+1
View File
@@ -72,6 +72,7 @@ use App\Models\ChatlogPrivate;
*/
class User extends Authenticatable implements FilamentUser, HasName
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasApiTokens, HasFactory, LogsActivity, Notifiable, TwoFactorAuthenticatable;
public $timestamps = false;