admin panel added and comments are working and likes are working

This commit is contained in:
ghassan committed 2026-03-03 17:36:19 +03:00
1 parent 72e9439727
commit a28023c29b
32 files changed
+5077 -2999

No files matched your search

+25 -4
View File
@@ -44,7 +44,9 @@ class Video extends Model
public function viewers()
{
return $this->belongsToMany(User::class, 'video_views')->withTimestamps();
return $this->belongsToMany(User::class, 'video_views')
->withPivot('watched_at')
->withTimestamps();
}
// Accessors
@@ -74,10 +76,10 @@ class Video extends Model
return $this->likes()->count();
}
// Get view count
// Get view count - use direct query to avoid timestamp issues
public function getViewCountAttribute()
{
return $this->viewers()->count();
return \DB::table('video_views')->where('video_id', $this->id)->count();
}
// Get shareable URL for the video
@@ -149,6 +151,15 @@ class Video extends Model
};
}
public function getTypeSymbolAttribute()
{
return match($this->type) {
'music' => '🎵',
'match' => '🏆',
default => '🎬',
};
}
public function isGeneric()
{
return $this->type === 'generic';
@@ -163,5 +174,15 @@ class Video extends Model
{
return $this->type === 'match';
}
}
// Comments relationship
public function comments()
{
return $this->hasMany(Comment::class)->latest();
}
public function getCommentCountAttribute()
{
return $this->comments()->count();
}
}