fill id with uuid everywhere
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user