Files
sam-api/app/Traits/ModelTrait.php

27 lines
510 B
PHP
Raw Normal View History

<?php
namespace App\Traits;
use DateTimeInterface;
trait ModelTrait
{
/**
* 날짜 직렬화 포맷 오버라이드 (모델에 추가해서 사용)
*
* ISO 8601 (2025-12-22T15:00:00.000000Z) Y-m-d (2025-12-22)
*/
protected function serializeDate(DateTimeInterface $date): string
{
return $date->format('Y-m-d');
}
/**
* Active 상태 조회
*/
public function scopeActive($query)
{
return $query->where('is_active', 1);
}
}