Add follow system, activity feed, notifications, sitemap, caching, Scout search
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use App\Services\ActivityService;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
@@ -10,6 +11,21 @@ class UserGame extends Model
|
||||
|
||||
const STATUSES = ['playing','played','want_to_play','on_hold','dropped'];
|
||||
|
||||
protected static function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::created(function (UserGame $ug) {
|
||||
ActivityService::log($ug->user, 'added_to_library', $ug->game, ['status' => $ug->status]);
|
||||
});
|
||||
|
||||
static::updated(function (UserGame $ug) {
|
||||
if ($ug->isDirty('rating') && $ug->rating) {
|
||||
ActivityService::log($ug->user, 'rated_game', $ug->game, ['rating' => $ug->rating]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function user(): BelongsTo { return $this->belongsTo(User::class); }
|
||||
public function game(): BelongsTo { return $this->belongsTo(Game::class); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user