lots of improvements

This commit is contained in:
Doar Mihai
2026-02-22 20:02:34 +02:00
parent 83fc389755
commit 29b5eca900
69 changed files with 3460 additions and 434 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ForumCategory extends Model
{
protected $fillable = [
'name',
'slug',
'description',
'order',
];
/**
* Get the threads for the category.
*/
public function threads()
{
return $this->hasMany(ForumThread::class, 'category_id');
}
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName()
{
return 'slug';
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ForumPost extends Model
{
protected $fillable = [
'topic_id',
'user_id',
'content',
'is_solution',
'edited_at',
];
protected $casts = [
'is_solution' => 'boolean',
'edited_at' => 'datetime',
];
/**
* Get the topic that owns the post.
*/
public function topic()
{
return $this->belongsTo(ForumTopic::class, 'topic_id');
}
/**
* Get the user that owns the post.
*/
public function user()
{
return $this->belongsTo(User::class);
}
}
+59
View File
@@ -0,0 +1,59 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ForumThread extends Model
{
protected $fillable = [
'category_id',
'user_id',
'title',
'slug',
'is_sticky',
'is_locked',
'views',
'last_activity_at',
];
protected $casts = [
'is_sticky' => 'boolean',
'is_locked' => 'boolean',
'last_activity_at' => 'datetime',
];
/**
* Get the category that owns the thread.
*/
public function category()
{
return $this->belongsTo(ForumCategory::class, 'category_id');
}
/**
* Get the user that owns the thread.
*/
public function user()
{
return $this->belongsTo(User::class);
}
/**
* Get the topics for the thread.
*/
public function topics()
{
return $this->hasMany(ForumTopic::class, 'thread_id');
}
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName()
{
return 'slug';
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ForumTopic extends Model
{
protected $fillable = [
'thread_id',
'user_id',
'title',
'content',
'is_pinned',
'last_activity_at',
];
protected $casts = [
'is_pinned' => 'boolean',
'last_activity_at' => 'datetime',
];
/**
* Get the thread that owns the topic.
*/
public function thread()
{
return $this->belongsTo(ForumThread::class, 'thread_id');
}
/**
* Get the user that owns the topic.
*/
public function user()
{
return $this->belongsTo(User::class);
}
/**
* Get the posts for the topic.
*/
public function posts()
{
return $this->hasMany(ForumPost::class, 'topic_id');
}
}
+6 -1
View File
@@ -16,7 +16,7 @@ class Review extends Model
'content',
'recommended',
'rating',
'platform',
'platform_id',
];
protected $casts = [
@@ -33,4 +33,9 @@ class Review extends Model
{
return $this->belongsTo(Game::class);
}
public function platform(): BelongsTo
{
return $this->belongsTo(Platform::class);
}
}
+27 -2
View File
@@ -9,11 +9,12 @@ use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Support\Str;
use Multicaret\Acquaintances\Traits\Friendable;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
use HasFactory, Notifiable, Friendable;
/**
* The attributes that are mass assignable.
@@ -47,7 +48,7 @@ class User extends Authenticatable
'password' => 'hashed',
];
protected static function boot()
protected static function boot(): void
{
parent::boot();
@@ -93,4 +94,28 @@ class User extends Authenticatable
{
return $this->hasMany(GameList::class);
}
/**
* Get the forum threads created by the user.
*/
public function forumThreads()
{
return $this->hasMany(ForumThread::class);
}
/**
* Get the forum topics created by the user.
*/
public function forumTopics()
{
return $this->hasMany(ForumTopic::class);
}
/**
* Get the forum posts created by the user.
*/
public function forumPosts()
{
return $this->hasMany(ForumPost::class);
}
}