Club System
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user