Club System

This commit is contained in:
2026-06-02 20:54:10 +02:00
parent c68c4d18b5
commit 0b18d289ef
38 changed files with 1464 additions and 118 deletions

View File

@@ -3,6 +3,8 @@
namespace App\Helpers;
use App\Auth\XenForoUser;
use App\Models\Entry;
use App\Services\XenforoApiService;
class XenForoHelpers {
@@ -34,4 +36,28 @@ class XenForoHelpers {
}
return self::XF_AVATAR_COLORS[ crc32( $user->data->username ) % count( self::XF_AVATAR_COLORS ) ];
}
public static function updateEntriesCount( int $userId ): void
{
$count = Entry::where('user_id', $userId)->where('state','published')->count();
$service = app(XenforoApiService::class);
$service->updateEntriesCount( $count, $userId );
}
public static function entryApproved( Entry $entry ): void
{
// 1. Update XF Entry count.
self::updateEntriesCount( $entry->user_id );
// 2. Send a private message
if( \Auth::user()->user_id === $entry->user_id ) {
return;
}
$moderator = \Auth::user()->username;
$title = "Entry approved : {$entry->title}";
$message = "Your entry {$entry->title} has been approved by {$moderator}.";
$service->createConversation([ $entry->user_id ], $title, $message, false, false);
}
}