50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models\Barobill;
|
||
|
|
|
||
|
|
use App\Traits\BelongsToTenant;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
|
||
|
|
class BarobillBankTransactionOverride extends Model
|
||
|
|
{
|
||
|
|
use BelongsToTenant;
|
||
|
|
|
||
|
|
protected $table = 'barobill_bank_transaction_overrides';
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'tenant_id',
|
||
|
|
'unique_key',
|
||
|
|
'modified_summary',
|
||
|
|
'modified_cast',
|
||
|
|
];
|
||
|
|
|
||
|
|
// =========================================================================
|
||
|
|
// 스코프
|
||
|
|
// =========================================================================
|
||
|
|
|
||
|
|
public function scopeByUniqueKey($query, string $uniqueKey)
|
||
|
|
{
|
||
|
|
return $query->where('unique_key', $uniqueKey);
|
||
|
|
}
|
||
|
|
|
||
|
|
// =========================================================================
|
||
|
|
// 헬퍼 메서드
|
||
|
|
// =========================================================================
|
||
|
|
|
||
|
|
public static function getByUniqueKeys(int $tenantId, array $uniqueKeys)
|
||
|
|
{
|
||
|
|
return static::where('tenant_id', $tenantId)
|
||
|
|
->whereIn('unique_key', $uniqueKeys)
|
||
|
|
->get()
|
||
|
|
->keyBy('unique_key');
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function saveOverride(int $tenantId, string $uniqueKey, ?string $modifiedSummary, ?string $modifiedCast): self
|
||
|
|
{
|
||
|
|
return static::updateOrCreate(
|
||
|
|
['tenant_id' => $tenantId, 'unique_key' => $uniqueKey],
|
||
|
|
['modified_summary' => $modifiedSummary, 'modified_cast' => $modifiedCast]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|