88 lines
2.2 KiB
PHP
88 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Member;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
|
|
|
class MemInfo extends Model
|
|
{
|
|
//
|
|
|
|
protected $table = 'mem_info';
|
|
protected $primaryKey = 'mem_no';
|
|
protected $keyType = 'int';
|
|
public $incrementing = true;
|
|
|
|
// 테이블이 legacy라 fillable 대신 guarded 추천 (내부에서만 쓰면 []도 가능)
|
|
protected $guarded = [];
|
|
|
|
// zero-date 때문에 datetime/date cast는 걸지 않음 (필요시 별도 accessor로 안전 파싱)
|
|
protected $casts = [
|
|
'admin_memo' => 'array',
|
|
'modify_log' => 'array',
|
|
];
|
|
|
|
/* =====================
|
|
* Relationships
|
|
* ===================== */
|
|
|
|
public function authInfo(): HasOne
|
|
{
|
|
return $this->hasOne(MemAuthInfo::class, 'mem_no', 'mem_no');
|
|
}
|
|
|
|
public function authRows(): HasMany
|
|
{
|
|
// mem_auth 복합키 테이블이지만 조회 관계는 문제 없음
|
|
return $this->hasMany(MemAuth::class, 'mem_no', 'mem_no');
|
|
}
|
|
|
|
public function authLogs(): HasMany
|
|
{
|
|
return $this->hasMany(MemAuthLog::class, 'mem_no', 'mem_no');
|
|
}
|
|
|
|
public function addresses(): HasMany
|
|
{
|
|
return $this->hasMany(MemAddress::class, 'mem_no', 'mem_no');
|
|
}
|
|
|
|
public function joinLogs(): HasMany
|
|
{
|
|
return $this->hasMany(MemJoinLog::class, 'mem_no', 'mem_no');
|
|
}
|
|
|
|
public function stRing(): HasOne
|
|
{
|
|
return $this->hasOne(MemStRing::class, 'mem_no', 'mem_no');
|
|
}
|
|
|
|
public function loginRecents(): HasMany
|
|
{
|
|
return $this->hasMany(MemLoginRecent::class, 'mem_no', 'mem_no');
|
|
}
|
|
|
|
public function modLogs(): HasMany
|
|
{
|
|
return $this->hasMany(MemModLog::class, 'mem_no', 'mem_no');
|
|
}
|
|
|
|
/* =====================
|
|
* Helpers (optional)
|
|
* ===================== */
|
|
|
|
public function isWithdrawn(): bool
|
|
{
|
|
// legacy: dt_out 기본값이 0000-00-00... 이므로 문자열 비교로 처리
|
|
return isset($this->attributes['dt_out']) && $this->attributes['dt_out'] !== '0000-00-00 00:00:00';
|
|
}
|
|
|
|
public function hasEmail(): bool
|
|
{
|
|
return !empty($this->attributes['email']);
|
|
}
|
|
}
|