2025-12-22 17:42:59 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2026-01-29 15:33:54 +09:00
|
|
|
use App\Traits\Auditable;
|
2025-12-22 17:42:59 +09:00
|
|
|
use App\Traits\BelongsToTenant;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
|
|
|
|
class NotificationSettingGroupState extends Model
|
|
|
|
|
{
|
2026-01-29 15:33:54 +09:00
|
|
|
use Auditable, BelongsToTenant;
|
2025-12-22 17:42:59 +09:00
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'tenant_id',
|
|
|
|
|
'user_id',
|
|
|
|
|
'group_code',
|
|
|
|
|
'enabled',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'enabled' => 'boolean',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 테넌트 관계
|
|
|
|
|
*/
|
|
|
|
|
public function tenant(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Tenant::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 사용자 관계
|
|
|
|
|
*/
|
|
|
|
|
public function user(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Scope: 특정 사용자의 설정
|
|
|
|
|
*/
|
|
|
|
|
public function scopeForUser($query, int $userId)
|
|
|
|
|
{
|
|
|
|
|
return $query->where('user_id', $userId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Scope: 특정 그룹
|
|
|
|
|
*/
|
|
|
|
|
public function scopeForGroup($query, string $groupCode)
|
|
|
|
|
{
|
|
|
|
|
return $query->where('group_code', $groupCode);
|
|
|
|
|
}
|
|
|
|
|
}
|