* @since 1.0.0 */ protected static array $columns = [ 'editor_doc_id' => ['name' => 'editor_doc_id', 'type' => 'int', 'internal' => 'id'], 'editor_doc_created_by' => ['name' => 'editor_doc_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], 'editor_doc_title' => ['name' => 'editor_doc_title', 'type' => 'string', 'internal' => 'title'], 'editor_doc_plain' => ['name' => 'editor_doc_plain', 'type' => 'string', 'internal' => 'plain'], 'editor_doc_content' => ['name' => 'editor_doc_content', 'type' => 'string', 'internal' => 'content'], 'editor_doc_virtual' => ['name' => 'editor_doc_virtual', 'type' => 'string', 'internal' => 'virtualPath'], 'editor_doc_created_at' => ['name' => 'editor_doc_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], 'editor_doc_visible' => ['name' => 'editor_doc_visible', 'type' => 'bool', 'internal' => 'isVisible'], ]; /** * Belongs to. * * @var array * @since 1.0.0 */ protected static array $belongsTo = [ 'createdBy' => [ 'mapper' => AccountMapper::class, 'external' => 'editor_doc_created_by', ], ]; /** * Has many relation. * * @var array * @since 1.0.0 */ protected static array $hasMany = [ 'tags' => [ 'mapper' => TagMapper::class, 'table' => 'editor_doc_tag', 'self' => 'editor_doc_tag_dst', 'external' => 'editor_doc_tag_src', ], 'media' => [ 'mapper' => MediaMapper::class, 'table' => 'editor_doc_media', 'external' => 'editor_doc_media_dst', 'self' => 'editor_doc_media_src', ], ]; /** * Primary table. * * @var string * @since 1.0.0 */ protected static string $table = 'editor_doc'; /** * Primary field name. * * @var string * @since 1.0.0 */ protected static string $primaryField = 'editor_doc_id'; /** * Created at. * * @var string * @since 1.0.0 */ protected static string $createdAt = 'editor_doc_created_at'; /** * Get editor doc based on virtual path. * * @param string $virtualPath Virtual path * @param int $account Account id * * @return array * * @since 1.0.0 */ public static function getByVirtualPath(string $virtualPath = '/', int $account = 0) : array { $depth = 3; $query = self::getQuery(depth: $depth); $query->where(self::$table . '_d' . $depth . '.editor_doc_virtual', '=', $virtualPath); $query->where(self::$table . '_d' . $depth . '.editor_doc_created_by', '=', $account); return self::getAllByQuery($query, RelationType::ALL, $depth); } }