Files
sam-manage/app/Models/Finance/CorporateCardPrepayment.php
김보곤 e272f16357 feat: [database] codebridge DB connection 적용 (merge 후 재적용)
- 78개 MNG 전용 모델에 $connection = 'codebridge' 재적용
- config/database.php codebridge connection 포함
2026-03-07 11:28:47 +09:00

30 lines
702 B
PHP

<?php
namespace App\Models\Finance;
use Illuminate\Database\Eloquent\Model;
class CorporateCardPrepayment extends Model
{
protected $table = 'corporate_card_prepayments';
protected $fillable = ['tenant_id', 'year_month', 'amount', 'memo', 'items'];
protected $casts = [
'items' => 'array',
];
public function scopeForTenant($query, int $tenantId)
{
return $query->where('tenant_id', $tenantId);
}
public static function getOrCreate(int $tenantId, string $yearMonth): self
{
return static::firstOrCreate(
['tenant_id' => $tenantId, 'year_month' => $yearMonth],
['amount' => 0, 'memo' => null]
);
}
}