Files
animexe/app/Models/ModeratorPermission.php
T
2026-07-14 00:01:48 +03:00

74 lines
2.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ModeratorPermission extends Model
{
public $timestamps = false;
protected $fillable = ['user_id', 'permission', 'granted_by'];
// Permission groups and their keys — single source of truth
public static array $groups = [
'Anime Yönetimi' => [
'animes.view' => 'Anime listesini görüntüle',
'animes.create' => 'Yeni anime ekle',
'animes.edit' => 'Anime düzenle',
'animes.delete' => 'Anime sil',
'animes.publish' => 'Anime yayınla / gizle',
],
'Bölüm Yönetimi' => [
'episodes.view' => 'Bölümleri görüntüle',
'episodes.create' => 'Bölüm ekle',
'episodes.edit' => 'Bölüm düzenle',
'episodes.delete' => 'Bölüm sil',
],
'Kullanıcı Yönetimi' => [
'users.view' => 'Kullanıcıları görüntüle',
'users.edit' => 'Kullanıcı bilgilerini düzenle',
'users.ban' => 'Kullanıcı banla / ban kaldır',
'users.premium' => 'Premium ver / al',
],
'Yorum Yönetimi' => [
'comments.view' => 'Yorumları görüntüle',
'comments.approve' => 'Yorum onayla / reddet',
'comments.delete' => 'Yorum sil',
'comments.pin' => 'Yorum sabitle',
],
'İçerik Yönetimi' => [
'genres.manage' => 'Türleri yönet',
'banners.manage' => 'Bannerleri yönet',
'requests.manage' => 'Anime isteklerini yönet',
'tribunal.manage' => 'Mahkeme yönet',
'import.manage' => 'Anime import et',
],
'Analitik & Raporlar' => [
'analytics.view' => 'Analitikleri görüntüle',
'analytics.bots' => 'Bot analitiğini görüntüle',
'analytics.block' => 'IP engelle / engel kaldır',
'analytics.users' => 'Kullanıcı analitiği & aktivite',
],
'Bildirimler' => [
'notifications.send' => 'Push bildirim gönder',
'notifications.view' => 'Bildirim geçmişini görüntüle',
],
];
public static function allKeys(): array
{
return collect(self::$groups)->flatMap(fn($g) => array_keys($g))->values()->all();
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function grantedBy(): BelongsTo
{
return $this->belongsTo(User::class, 'granted_by');
}
}