Sapphire Documentation

Sapphire\Page\Page

class Page


protected int|null    $id

protected int         $parent_id

protected string      $name

protected string      $subname

protected string      $content

protected string      $url

protected string      $layout

protected bool        $is_home

protected string      $created_at

protected string      $created_by

protected string      $updated_at

protected string      $updated_by


public function __construct(null|int $parentId = null) - Constucts class

public function CreateToDatabase(): void - Inserts page to database


public function GetParentId(): int     

public function GetId(): int

public function GetName(): string

public function GetSubname(): string

public function GetContent(): string

public function GetUrl(): string

public function IsHome(): bool

public function GetLayout(): Layout | null - Returns layout of our page

public function Children(): array - Returns all children pages

public function Parent(): Page | null - Returns Page parent

public function Siblings(): array - Returns Page siblings

public function GetFullUrl(string $previous = '): string - Returns full url of page using parent pages

public function Save(): void - Saves page

public function ToArray(): array - Returns page as array of key-value pairs

public function ToArrayWithoutKeys(): array - Returns page as array of properties

public function Serialize(): string | array | stdClass - Returns Json maked serialized array of this class


public static function ById(int $id): Page | null - Returns page which id: $id

public static function From(stdClass|null|bool $page_class): Page|null - Returns Page class instance from given stdClass json

public static function GetByUrlAndParentId(string $url, int $parent_id): Page | null - Returns Page that url matches passed url and parent_id matches passed id

public static function GetChildren(int $parent_id): array - Returns Page children

public static function GetParent(int $id): Page | null - Returns Page parent

public static function GetSiblings(int $id): array - Returns Page siblings

public static function GetProperties(int $page_id): array - Returns all properties of page

public static function AllArray(): array - Returns all pages

public static function ClearHomePage(): void - Removes `is_home` (set it to 0) to all pages

public static function GetNewPageIndex() - Returns new page index :=> (New Page #(index))

public static function Create(int $parentId): Page - Returns new page (created by ui)

public static function Current(): Page | null - Returns currently viewed page by url

public static function Home(): Page - Returns home page


public function Set(stdClass $data) - Set privates properties from stdClass object