Initial GameLog setup
- Laravel 11 + Breeze (dark mode) + Tailwind + Alpine.js - Migrations: games, genres, platforms, companies, pivots, user_games, user_lists, reviews, follows, activities - Models: Game, Genre, Platform, Company, UserGame, UserList, Review, ReviewVote, Activity, User (with gamelog fields) - IgdbService: OAuth2 token management, search, game fetch, popular/new releases, genre filter, cover/screenshot URL helpers - IGDB credentials in config/services.php (from .env)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Activity extends Model
|
||||
{
|
||||
protected $fillable = ['user_id','type','subject_type','subject_id','data'];
|
||||
protected $casts = ['data'=>'array'];
|
||||
|
||||
public function user(): BelongsTo { return $this->belongsTo(User::class); }
|
||||
public function subject() { return $this->morphTo(); }
|
||||
|
||||
public static function log(int $userId, string $type, mixed $subject = null, array $data = []): self
|
||||
{
|
||||
return static::create([
|
||||
'user_id' => $userId,
|
||||
'type' => $type,
|
||||
'subject_type' => $subject ? get_class($subject) : null,
|
||||
'subject_id' => $subject?->id,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user