/** Datei: library/ARUNOX/API/PHP/Attributes/Database/Definitions/Model.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\API\PHP\Attributes\Database\Definitions; use Attribute; use ARUNOX\API\PHP; #[Attribute( Attribute::TARGET_CLASS )] class Model extends PHP\Attributes\Attribute { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ public function getModelClass() : string|bool { return $this->class; } public function callModelClass( string $method, ...$args ) { return $this->getModelClass()::{$method}( ...$args ); } /* ### PROTECTED FUNCTIONS ###################################### # */ /* ### MAGIC FUNCTIONS ########################################## # */ public function __construct( protected string $class ){ parent::__construct( $class ); } } /** Datei: library/ARUNOX/API/PHP/Attributes/Database/Definitions/HashID.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\API\PHP\Attributes\Database\Definitions; use Attribute; use ARUNOX\API\PHP; use Hashids\Hashids; use ARUNOX\Core\Hooks; #[Attribute( Attribute::TARGET_CLASS )] class HashID extends PHP\Attributes\Attribute { /* ### VARIABLES ################################################ # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function getHashIDPrefix() : string { return $this->prefix; } public function getHashID( int $primary ) : string { $prefix = $this->getHashIDPrefix() ?? $this->getTable(); $hashids = new Hashids( $this->getTable(), 16 ); $numbers = [ $primary ]; $numbers = Hooks::filterWithNames( "model::hashids", $this->getTable(), $numbers, $this->getTable() ); $encoded = $hashids->encode( $numbers ); $hashid = "{$this->prefix}_{$encoded}"; return $hashid; } public function resolveHashID( string $hashid, null|int $index = 0 ) : int|bool|array { $prefix = $this->getHashIDPrefix() ?? $this->getTable(); $hashid = explode( "_", $hashid ); if( $hashid[0] !== $prefix ) return FALSE; $sqids = new Hashids( $this->getTable(), 16 ); $decoded = $sqids->decode( $hashid[1] ); if( !$decoded ) return FALSE; return $index === NULL ? $decoded : $decoded[ $index ]; } public function resolveHashIDPrefix( string $hashid, null|string $column = NULL ) { $split = explode( "_", $hashid ); $class = array_search( $split[0], $this->getCacheAll() ); if( !$class ) return NULL; $data = $class::get( $hashid ); if( $column ) return $data->{$column} ?? NULL; return $data; } /* ### PROTECTED FUNCTIONS ###################################### # */ /* ### PRIVATE FUNCTIONS ######################################## # */ private function getTable() : string { return $this->getParentClass()::getTable(); } /* ### MAGIC FUNCTIONS ########################################## # */ public function __construct( protected string $prefix ){ parent::__construct( $prefix ); } } /** Datei: library/ARUNOX/API/PHP/Attributes/Database/Definitions/Table.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\API\PHP\Attributes\Database\Definitions; use Attribute; use ARUNOX\API\PHP; #[Attribute( Attribute::TARGET_CLASS )] class Table extends PHP\Attributes\Attribute { /* ### VARIABLES ################################################ # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function getTable( null|string $suffix = NULL ) { return implode( "_", array_filter( [ $this->table, $suffix ] ) ); } public function resolveTable( string $table ) { $class = array_search( $table, $this->getCacheAll() ); if( !$class ) return NULL; return $class; } /* ### PROTECTED FUNCTIONS ###################################### # */ /* ### MAGIC FUNCTIONS ########################################## # */ public function __construct( protected string $table, ){ parent::__construct( $table ); } } /** Datei: library/ARUNOX/API/PHP/Attributes/Database/Definitions/Entity.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\API\PHP\Attributes\Database\Definitions; use Attribute; use ARUNOX\API\PHP; #[Attribute( Attribute::TARGET_CLASS )] class Entity extends PHP\Attributes\Attribute { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ public function getEntityClass() : string|bool { return $this->class; } public function callEntityClass( string $method, ...$args ) { return $this->getEntityClass()::{$method}( ...$args ); } /* ### PROTECTED FUNCTIONS ###################################### # */ /* ### MAGIC FUNCTIONS ########################################## # */ public function __construct( protected string $class ){ parent::__construct( $class ); } } /** Datei: library/ARUNOX/API/PHP/Attributes/Database/Definitions/Origin.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\API\PHP\Attributes\Database\Definitions; use Attribute; use ARUNOX\API\PHP; use ARUNOX\Autoloader; #[Attribute( Attribute::TARGET_CLASS )] class Origin extends PHP\Attributes\Attribute { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ public function getOriginClass() : string|bool { return $this->class; } public function callOriginClass( string $method, ...$args ) { return $this->getOriginClass()::{$method}( ...$args ); } public function getControllerClass() { return Autoloader::find( $this->getNamespace(), "controller" ); } public function callControllerClass( string $method, ...$args ) { return $this->getControllerClass()::{$method}( ...$args ); } /* ### PROTECTED FUNCTIONS ###################################### # */ /* ### MAGIC FUNCTIONS ########################################## # */ public function __construct( protected string $class ){ parent::__construct( $class ); } }