fill id with uuid everywhere

This commit is contained in:
Daan Meijer
2026-06-23 17:17:47 +02:00
parent e7481eac95
commit ae925c7173
7 changed files with 36 additions and 8 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Concerns;
trait SerializesIdToUuid
{
/**
* Convert the model's attributes to an array.
* Overrides the default model toArray method to replace 'id' with 'uuid'.
*
* @return array<string, mixed>
*/
public function toArray(): array
{
$array = parent::toArray();
if (isset($this->uuid)) {
$array['id'] = $this->uuid;
}
return $array;
}
}