2023-10-02 23:10:49 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Lucent\Revision;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\Str;
|
2023-10-15 19:14:07 +03:00
|
|
|
use Lucent\Edge\EdgeCollection;
|
2023-10-02 23:10:49 +03:00
|
|
|
use Lucent\Record\File;
|
|
|
|
|
use Lucent\Record\Record;
|
|
|
|
|
use Lucent\Record\RecordData;
|
|
|
|
|
use Lucent\Record\System;
|
|
|
|
|
|
|
|
|
|
readonly class Revision
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
function __construct(
|
2023-10-15 19:14:07 +03:00
|
|
|
public string $id,
|
|
|
|
|
public string $recordId,
|
|
|
|
|
public string $schema,
|
|
|
|
|
public System $_sys,
|
|
|
|
|
public RecordData $data,
|
|
|
|
|
public EdgeCollection $_edges,
|
|
|
|
|
public ?File $_file = null,
|
2023-10-02 23:10:49 +03:00
|
|
|
|
2023-10-15 19:14:07 +03:00
|
|
|
)
|
2023-10-02 23:10:49 +03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-10-15 19:14:07 +03:00
|
|
|
public static function fromRecord(Record $record, EdgeCollection $edges): Revision
|
2023-10-02 23:10:49 +03:00
|
|
|
{
|
|
|
|
|
return new Revision(
|
|
|
|
|
id: (string)Str::uuid(),
|
|
|
|
|
recordId: $record->id,
|
2023-10-04 13:32:30 +03:00
|
|
|
schema: $record->schema,
|
2023-10-02 23:10:49 +03:00
|
|
|
_sys: $record->_sys,
|
|
|
|
|
data: $record->data,
|
2023-10-15 19:14:07 +03:00
|
|
|
_edges: $edges,
|
|
|
|
|
_file: $record->_file
|
2023-10-02 23:10:49 +03:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|