feat(attachments): ensure 'key' is set as UUID on attachment creation and update tests for key validation
This commit is contained in:
@@ -12,6 +12,7 @@ use Illuminate\Support\Str;
|
||||
#[Fillable([
|
||||
'attachable_type',
|
||||
'attachable_id',
|
||||
'key',
|
||||
'path',
|
||||
'filename',
|
||||
'type',
|
||||
@@ -28,7 +29,9 @@ class Attachment extends Model
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (self $attachment): void {
|
||||
$attachment->key = (string) Str::uuid();
|
||||
if (! $attachment->key) {
|
||||
$attachment->key = (string) Str::uuid();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user