mirror of
https://github.com/m1ngsama/php.git
synced 2025-12-24 16:01:19 +00:00
Added Community, Post, Comment, and Vote models with proper relationships. Updated User model to include karma field and forum-related relationships.
35 lines
569 B
PHP
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();
|
|
}
|
|
}
|