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

+30
View File
@@ -14,9 +14,11 @@ class User extends Authenticatable
protected $fillable = [
'name',
'username',
'email',
'password',
'avatar',
'role',
];
protected $hidden = [
@@ -45,6 +47,11 @@ class User extends Authenticatable
return $this->belongsToMany(Video::class, 'video_views')->withTimestamps();
}
public function comments()
{
return $this->hasMany(Comment::class);
}
public function getAvatarUrlAttribute()
{
if ($this->avatar) {
@@ -52,5 +59,28 @@ class User extends Authenticatable
}
return 'https://i.pravatar.cc/150?u=' . $this->id;
}
// Role helper methods
public function isSuperAdmin()
{
return $this->role === 'super_admin';
}
public function isAdmin()
{
return in_array($this->role, ['admin', 'super_admin']);
}
public function isUser()
{
return $this->role === 'user' || $this->role === null;
}
// Placeholder for subscriber count (would need a separate table in full implementation)
public function getSubscriberCountAttribute()
{
// For now, return a placeholder - in production this would come from a subscriptions table
return rand(100, 10000);
}
}