Add casts for location model

This commit is contained in:
David Bomba 2025-02-27 07:55:43 +11:00
parent 2bebfb0b85
commit 35f4aec6e3
4 changed files with 12 additions and 1 deletions

View File

@ -50,6 +50,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property string|null $custom_value4
* @property bool $is_deleted
* @property bool $is_shipping_location
* @property object|array|null $tax_data
* @property int|null $created_at
* @property int|null $updated_at
* @property int|null $deleted_at
@ -91,6 +92,13 @@ class Location extends BaseModel
'is_shipping_location',
];
protected $casts = [
'tax_data' => 'object',
'updated_at' => 'timestamp',
'created_at' => 'timestamp',
'deleted_at' => 'timestamp',
'is_deleted' => 'bool',
];
protected $touches = [];

View File

@ -34,6 +34,7 @@ class ClientTransformer extends EntityTransformer
'contacts',
'documents',
'gateway_tokens',
'locations',
];
/**
@ -44,7 +45,6 @@ class ClientTransformer extends EntityTransformer
'ledger',
'system_logs',
'group_settings',
'locations',
];
/**

View File

@ -58,6 +58,7 @@ class LocationTransformer extends EntityTransformer
'custom_value3' => $location->custom_value3 ?: '',
'custom_value4' => $location->custom_value4 ?: '',
'is_deleted' => (bool) $location->is_deleted,
'tax_data' => $location->tax_data ?: new \stdClass(),
'updated_at' => (int) $location->updated_at,
'archived_at' => (int) $location->deleted_at,
'created_at' => (int) $location->created_at,

View File

@ -34,6 +34,8 @@ return new class extends Migration
$table->text('custom_value3')->nullable();
$table->text('custom_value4')->nullable();
$table->mediumText('tax_data')->nullable();
$table->softDeletes('deleted_at', 6);
$table->timestamps(6);