Snapshot of main at 9f39a6e1e (2026-11-02)
This commit is contained in:
commit
6ccf1792d7
2580 files changed
+1040202
No files matched your search
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
// 4. Trait for User Models (add to all your auth models)
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Services\PresenceService;
|
||||
|
||||
trait HasPresence
|
||||
{
|
||||
public function updatePresence($guard = null)
|
||||
{
|
||||
app(PresenceService::class)->updatePresence($this, $guard);
|
||||
}
|
||||
|
||||
public function isOnline($guard = 'web', $minutes = 5)
|
||||
{
|
||||
return app(PresenceService::class)->isUserOnline($this, $guard, $minutes);
|
||||
}
|
||||
|
||||
public function getLastSeenAttribute($guard = 'web')
|
||||
{
|
||||
return app(PresenceService::class)->getUserLastSeen($this, $guard);
|
||||
}
|
||||
|
||||
public function scopeOnline($query, $guard = 'web', $minutes = 5)
|
||||
{
|
||||
$onlineUsers = app(PresenceService::class)->getOnlineUsers($guard, $minutes);
|
||||
$onlineIds = $onlineUsers->where('user_type', static::class)->pluck('id');
|
||||
|
||||
return $query->whereIn('id', $onlineIds);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user