giftcon_dev/app/Models/CounselingOneOnOne.php

38 lines
896 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
final class CounselingOneOnOne extends Model
{
// ⚠️ 기본 table은 의미 없음. queryForYear()로 강제 지정해서 씀.
protected $table = 'counseling_one_on_one_'.'0000';
protected $primaryKey = 'seq';
public $incrementing = true;
public $timestamps = false;
protected $guarded = [];
public static function queryForYear(int $year): Builder
{
$m = new static();
$m->setTable('counseling_one_on_one_'.$year);
return $m->newQuery();
}
public function regdateCarbon(): ?Carbon
{
$v = $this->regdate ?? null;
if (!$v) return null;
try {
return Carbon::parse($v);
} catch (\Throwable) {
return null;
}
}
}