edges wip
This commit is contained in:
@@ -4,6 +4,8 @@ use Carbon\Carbon;
|
||||
use Lucent\Core\Data\Record;
|
||||
use Lucent\Core\Data\RecordPreview;
|
||||
use Lucent\Core\Data\RecordStatus;
|
||||
use Lucent\Core\Data\EdgeRecordPreview;
|
||||
use Lucent\Core\Edge\EdgeModule;
|
||||
use stdClass;
|
||||
|
||||
class RecordModule
|
||||
@@ -68,12 +70,45 @@ class RecordModule
|
||||
);
|
||||
}
|
||||
|
||||
public static function recordPreviewFromDb(stdClass $data): RecordPreview
|
||||
{
|
||||
/**
|
||||
* @param Schema[] $schemas
|
||||
* @param stdClass $data
|
||||
* @return RecordPreview
|
||||
*/
|
||||
public static function recordPreviewFromDb(
|
||||
array $schemas,
|
||||
stdClass $data,
|
||||
): RecordPreview {
|
||||
return new RecordPreview(
|
||||
id: data_get($data, "id"),
|
||||
schemaId: data_get($data, "schema_id"),
|
||||
schemaName: collect($schemas)
|
||||
->where("id", data_get($data, "schema_id"))
|
||||
->first()->name,
|
||||
|
||||
title: data_get($data, "title"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema[] $schemas
|
||||
* @param stdClass $data
|
||||
* @return EdgeRecordPreview
|
||||
*/
|
||||
public static function edgeRecordPreviewFromDb(
|
||||
array $schemas,
|
||||
stdClass $data,
|
||||
): EdgeRecordPreview {
|
||||
return new EdgeRecordPreview(
|
||||
edge: EdgeModule::fromDb($data),
|
||||
recordPreview: new RecordPreview(
|
||||
id: data_get($data, "record_id"),
|
||||
schemaId: data_get($data, "record_schema_id"),
|
||||
schemaName: collect($schemas)
|
||||
->where("id", data_get($data, "record_schema_id"))
|
||||
->first()->name,
|
||||
title: data_get($data, "record_title"),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user