php/app/Models/Vote.php
m1ngsama b453c1020a Implement Eloquent models and relationships
Added Community, Post, Comment, and Vote models with proper relationships.
Updated User model to include karma field and forum-related relationships.
2025-11-29 14:15:00 +08:00

35 lines
569 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Vote extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'voteable_id',
'voteable_type',
'vote',
];
protected function casts(): array
{
return [
'vote' => 'integer',
];
}
public function user()
{
return $this->belongsTo(User::class);
}
public function voteable()
{
return $this->morphTo();
}
}