TDoG-Skin/app/Listeners/ResetPlayers.php
2024-08-17 19:13:54 +08:00

29 lines
675 B
PHP
Executable File

<?php
namespace App\Listeners;
use App\Models\Player;
use App\Models\Texture;
class ResetPlayers
{
public function handle(Texture $texture)
{
// no need to update players
// if texture was switched from "private" to "public"
if ($texture->exists && $texture->public) {
return;
}
$type = $texture->type == 'cape' ? 'tid_cape' : 'tid_skin';
$query = Player::where($type, $texture->tid);
// texture was switched from "private" to "public"
if ($texture->exists) {
$query = $query->where('uid', '<>', $texture->uploader);
}
$query->update([$type => 0]);
}
}