feat(spaces): stamp bank-synced rows and hide internal space_id

Set space_id explicitly on bank-sync transaction inserts (avoids a per-row
lookup during sync and anchors the row to the account's space), and hide the
internal space_id foreign key from model serialization.
This commit is contained in:
Víctor Falcón 2026-07-06 16:41:16 +02:00
parent c541dfc104
commit 6b9a1d1b74
6 changed files with 10 additions and 0 deletions

View File

@ -34,6 +34,11 @@ class AutomationRule extends Model
'action_note_iv',
];
/** @var list<string> */
protected $hidden = [
'space_id',
];
protected function casts(): array
{
return [

View File

@ -54,6 +54,7 @@ class BankingConnection extends Model
];
protected $hidden = [
'space_id',
'api_token',
'api_secret',
'pending_accounts_data',

View File

@ -34,6 +34,7 @@ class Budget extends Model
/** @var list<string> */
protected $hidden = [
'period_duration',
'space_id',
];
protected function casts(): array

View File

@ -31,6 +31,7 @@ class Label extends Model
*/
protected $hidden = [
'pivot',
'space_id',
];
/** @return BelongsTo<User, $this> */

View File

@ -115,6 +115,7 @@ class TransactionSyncService
try {
$account->transactions()->create([
'user_id' => $account->user_id,
'space_id' => $account->space_id,
'description' => $formatted['description'],
'description_iv' => null,
'original_description' => $formatted['original_description'],

View File

@ -166,6 +166,7 @@ class WiseTransactionSyncService
try {
$account->transactions()->create([
'user_id' => $account->user_id,
'space_id' => $account->space_id,
'description' => $parsed['description'],
'description_iv' => null,
'original_description' => $parsed['description'],