Standardize enum static methods across PHP and JavaScript
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -167,15 +167,16 @@ class Document_Models_Command extends FrameworkDeveloperCommand
|
|||||||
|
|
||||||
if (property_exists($className, 'enums') && !empty($className::$enums)) {
|
if (property_exists($className, 'enums') && !empty($className::$enums)) {
|
||||||
foreach ($className::$enums as $columnName => $enumDefinitions) {
|
foreach ($className::$enums as $columnName => $enumDefinitions) {
|
||||||
// Add enum accessor properties
|
// Add enum accessor properties (instance properties for current value)
|
||||||
$enumProperties[] = " * @property-read string \${$columnName}_label";
|
$enumProperties[] = " * @property-read string \${$columnName}_label";
|
||||||
$enumProperties[] = " * @property-read string \${$columnName}_constant";
|
$enumProperties[] = " * @property-read string \${$columnName}_constant";
|
||||||
$enumProperties[] = " * @property-read array \${$columnName}_enum_val";
|
$enumProperties[] = " * @property-read array \${$columnName}_enum_val";
|
||||||
|
|
||||||
// Add enum static methods
|
// Add enum static methods (mirrored in JavaScript stubs)
|
||||||
$enumMethods[] = " * @method static array {$columnName}_enum()";
|
$enumMethods[] = " * @method static array {$columnName}_enum_val() Get all enum definitions with full metadata";
|
||||||
$enumMethods[] = " * @method static array {$columnName}_enum_select()";
|
$enumMethods[] = " * @method static array {$columnName}_enum_select() Get selectable items for dropdowns";
|
||||||
$enumMethods[] = " * @method static array {$columnName}_enum_ids()";
|
$enumMethods[] = " * @method static array {$columnName}_enum_labels() Get simple id => label map";
|
||||||
|
$enumMethods[] = " * @method static array {$columnName}_enum_ids() Get array of all valid enum IDs";
|
||||||
|
|
||||||
// Generate constants for each enum value
|
// Generate constants for each enum value
|
||||||
foreach ($enumDefinitions as $value => $definition) {
|
foreach ($enumDefinitions as $value => $definition) {
|
||||||
|
|||||||
@@ -31,8 +31,29 @@ use App\RSpade\Core\Models\User_Model;
|
|||||||
* @property \Carbon\Carbon $created_at
|
* @property \Carbon\Carbon $created_at
|
||||||
* @property \Carbon\Carbon $updated_at
|
* @property \Carbon\Carbon $updated_at
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
|
* Generated on: 2025-12-10 02:59:31
|
||||||
|
* Table: _api_keys
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property int $user_id
|
||||||
|
* @property mixed $name
|
||||||
|
* @property mixed $key_hash
|
||||||
|
* @property mixed $key_prefix
|
||||||
|
* @property int $user_role_id
|
||||||
|
* @property string $last_used_at
|
||||||
|
* @property string $expires_at
|
||||||
|
* @property bool $is_revoked
|
||||||
|
* @property string $created_at
|
||||||
|
* @property string $updated_at
|
||||||
|
* @property int $created_by
|
||||||
|
* @property int $updated_by
|
||||||
|
*
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
class Api_Key_Model extends Rsx_System_Model_Abstract
|
class Api_Key_Model extends Rsx_System_Model_Abstract
|
||||||
{
|
{
|
||||||
protected $table = '_api_keys';
|
protected $table = '_api_keys';
|
||||||
|
|
||||||
public static $enums = [];
|
public static $enums = [];
|
||||||
|
|||||||
@@ -383,21 +383,7 @@ class Database_BundleIntegration extends BundleIntegration_Abstract
|
|||||||
$content .= " });\n";
|
$content .= " });\n";
|
||||||
$content .= " }\n\n";
|
$content .= " }\n\n";
|
||||||
|
|
||||||
// Generate enum label list
|
// Generate enum_select() - Selectable items for dropdowns (respects selectable: false)
|
||||||
$content .= " static {$column}_label_list() {\n";
|
|
||||||
$content .= " const values = {};\n";
|
|
||||||
foreach ($enum_values as $value => $props) {
|
|
||||||
if (isset($props['label'])) {
|
|
||||||
$value_json = json_encode($value);
|
|
||||||
$label = addslashes($props['label']);
|
|
||||||
$content .= " values[{$value_json}] = '{$label}';\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$content .= " return values;\n";
|
|
||||||
$content .= " }\n\n";
|
|
||||||
|
|
||||||
// Generate enum select method (for dropdowns)
|
|
||||||
// Consumes enum_val() data and extracts labels for selectable items
|
|
||||||
$content .= " static {$column}_enum_select() {\n";
|
$content .= " static {$column}_enum_select() {\n";
|
||||||
$content .= " const fullData = this.{$column}_enum_val();\n";
|
$content .= " const fullData = this.{$column}_enum_val();\n";
|
||||||
$content .= " const data = {};\n";
|
$content .= " const data = {};\n";
|
||||||
@@ -428,6 +414,27 @@ class Database_BundleIntegration extends BundleIntegration_Abstract
|
|||||||
$content .= " }\n";
|
$content .= " }\n";
|
||||||
$content .= " });\n";
|
$content .= " });\n";
|
||||||
$content .= " }\n\n";
|
$content .= " }\n\n";
|
||||||
|
|
||||||
|
// Generate enum_labels() - Simple id => label map (all items, ignores selectable)
|
||||||
|
$content .= " static {$column}_enum_labels() {\n";
|
||||||
|
$content .= " const values = {};\n";
|
||||||
|
foreach ($enum_values as $value => $props) {
|
||||||
|
if (isset($props['label'])) {
|
||||||
|
$value_json = json_encode($value);
|
||||||
|
$label = addslashes($props['label']);
|
||||||
|
$content .= " values[{$value_json}] = '{$label}';\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$content .= " return values;\n";
|
||||||
|
$content .= " }\n\n";
|
||||||
|
|
||||||
|
// Generate enum_ids() - Array of all valid enum IDs
|
||||||
|
$content .= " static {$column}_enum_ids() {\n";
|
||||||
|
$content .= " return [";
|
||||||
|
$ids = array_keys($enum_values);
|
||||||
|
$content .= implode(', ', array_map('json_encode', $ids));
|
||||||
|
$content .= "];\n";
|
||||||
|
$content .= " }\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate static get_relationships() method
|
// Generate static get_relationships() method
|
||||||
|
|||||||
@@ -40,9 +40,13 @@ use RuntimeException;
|
|||||||
* This provides magic properties and methods:
|
* This provides magic properties and methods:
|
||||||
* - $model->status_label - Get label for current enum value
|
* - $model->status_label - Get label for current enum value
|
||||||
* - $model->status_constant - Get constant name for current value
|
* - $model->status_constant - Get constant name for current value
|
||||||
* - Model::status_enum() - Get all enum definitions
|
* - $model->status_enum_val - Get all properties for current value
|
||||||
* - Model::status_enum_select() - Get key/label pairs for dropdowns
|
*
|
||||||
* - Model::status_enum_ids() - Get all possible enum values
|
* Static methods (available in both PHP and JavaScript):
|
||||||
|
* - Model::status_enum_val() - Get all enum definitions with full metadata
|
||||||
|
* - Model::status_enum_select() - Get selectable items for dropdowns (respects selectable: false)
|
||||||
|
* - Model::status_enum_labels() - Get simple id => label lookup map
|
||||||
|
* - Model::status_enum_ids() - Get array of all valid enum IDs
|
||||||
*/
|
*/
|
||||||
#[Monoprogenic]
|
#[Monoprogenic]
|
||||||
#[Instantiatable]
|
#[Instantiatable]
|
||||||
@@ -82,10 +86,11 @@ abstract class Rsx_Model_Abstract extends Model
|
|||||||
/**
|
/**
|
||||||
* Private helper to resolve enum magic properties and methods
|
* Private helper to resolve enum magic properties and methods
|
||||||
*
|
*
|
||||||
* Handles:
|
* Handles (these are mirrored in JavaScript stubs):
|
||||||
* - field_enum() - Returns all enum definitions for a field
|
* - field_enum_val() - Returns all enum definitions with full metadata
|
||||||
* - field_enum_select() - Returns key/label pairs for dropdowns
|
* - field_enum_select() - Returns selectable items for dropdowns
|
||||||
* - field_enum_ids() - Returns all possible enum values
|
* - field_enum_labels() - Returns simple id => label map
|
||||||
|
* - field_enum_ids() - Returns array of all valid enum IDs
|
||||||
*
|
*
|
||||||
* @param string $key The property/method being accessed
|
* @param string $key The property/method being accessed
|
||||||
* @param mixed $value Optional value for filtering selectable items
|
* @param mixed $value Optional value for filtering selectable items
|
||||||
@@ -114,10 +119,12 @@ abstract class Rsx_Model_Abstract extends Model
|
|||||||
return $keyA <=> $keyB;
|
return $keyA <=> $keyB;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($key == $column . '_enum') {
|
// field_enum_val() - All enum definitions with full metadata
|
||||||
|
if ($key == $column . '_enum_val') {
|
||||||
return $sorted_config;
|
return $sorted_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// field_enum_select() - Selectable items for dropdowns (respects selectable: false)
|
||||||
if ($key == $column . '_enum_select') {
|
if ($key == $column . '_enum_select') {
|
||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
@@ -133,6 +140,18 @@ abstract class Rsx_Model_Abstract extends Model
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// field_enum_labels() - Simple id => label map (all items, ignores selectable)
|
||||||
|
if ($key == $column . '_enum_labels') {
|
||||||
|
$return = [];
|
||||||
|
foreach ($sorted_config as $k => $v) {
|
||||||
|
if (isset($v['label'])) {
|
||||||
|
$return[$k] = $v['label'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// field_enum_ids() - Array of all valid enum IDs
|
||||||
if ($key == $column . '_enum_ids') {
|
if ($key == $column . '_enum_ids') {
|
||||||
return array_keys($sorted_config);
|
return array_keys($sorted_config);
|
||||||
}
|
}
|
||||||
@@ -228,10 +247,11 @@ abstract class Rsx_Model_Abstract extends Model
|
|||||||
/**
|
/**
|
||||||
* Magic static method handler for enum methods
|
* Magic static method handler for enum methods
|
||||||
*
|
*
|
||||||
* Provides static access to:
|
* Provides static access to (mirrored in JavaScript stubs):
|
||||||
* - Model::field_enum() - All enum definitions
|
* - Model::field_enum_val() - All enum definitions with full metadata
|
||||||
* - Model::field_enum_select() - Key/label pairs for dropdowns
|
* - Model::field_enum_select() - Selectable items for dropdowns
|
||||||
* - Model::field_enum_ids() - All possible enum values
|
* - Model::field_enum_labels() - Simple id => label map
|
||||||
|
* - Model::field_enum_ids() - Array of all valid enum IDs
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param array $args
|
* @param array $args
|
||||||
|
|||||||
@@ -30,42 +30,51 @@ use App\RSpade\Core\Files\File_Storage_Model;
|
|||||||
* provides the basic structure for categorizing uploaded files.
|
* provides the basic structure for categorizing uploaded files.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* @property integer $id
|
* Generated on: 2025-12-10 02:59:31
|
||||||
* @property string $key
|
* Table: _file_attachments
|
||||||
* @property integer $file_storage_id
|
*
|
||||||
* @property string $file_name
|
* @property int $id
|
||||||
* @property string $file_extension
|
* @property mixed $key
|
||||||
* @property integer $file_type_id
|
* @property int $file_storage_id
|
||||||
* @property integer $width
|
* @property mixed $file_name
|
||||||
* @property integer $height
|
* @property mixed $file_extension
|
||||||
* @property integer $duration
|
* @property int $file_type_id
|
||||||
* @property boolean $is_animated
|
* @property int $width
|
||||||
* @property integer $frame_count
|
* @property int $height
|
||||||
* @property string $fileable_type
|
* @property int $duration
|
||||||
* @property integer $fileable_id
|
* @property bool $is_animated
|
||||||
* @property string $fileable_category
|
* @property int $frame_count
|
||||||
* @property string $fileable_type_meta
|
* @property mixed $fileable_type
|
||||||
* @property integer $fileable_order
|
* @property int $fileable_id
|
||||||
|
* @property mixed $fileable_category
|
||||||
|
* @property mixed $fileable_type_meta
|
||||||
|
* @property int $fileable_order
|
||||||
* @property string $fileable_meta
|
* @property string $fileable_meta
|
||||||
* @property integer $site_id
|
* @property int $site_id
|
||||||
* @property string $session_id
|
* @property mixed $session_id
|
||||||
* @property \Carbon\Carbon $created_at
|
* @property string $created_at
|
||||||
* @property \Carbon\Carbon $updated_at
|
* @property string $updated_at
|
||||||
* @property integer $created_by
|
* @property int $created_by
|
||||||
* @property integer $updated_by
|
* @property int $updated_by
|
||||||
* @method static mixed file_type_id_enum()
|
*
|
||||||
* @method static mixed file_type_id_enum_select()
|
* @property-read string $file_type_id_label
|
||||||
* @method static mixed file_type_id_enum_ids()
|
* @property-read string $file_type_id_constant
|
||||||
* @property-read mixed $file_type_id_constant
|
* @property-read array $file_type_id_enum_val
|
||||||
* @property-read mixed $file_type_id_label
|
*
|
||||||
|
* @method static array file_type_id_enum_val() Get all enum definitions with full metadata
|
||||||
|
* @method static array file_type_id_enum_select() Get selectable items for dropdowns
|
||||||
|
* @method static array file_type_id_enum_labels() Get simple id => label map
|
||||||
|
* @method static array file_type_id_enum_ids() Get array of all valid enum IDs
|
||||||
|
*
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class File_Attachment_Model extends Rsx_Site_Model_Abstract
|
class File_Attachment_Model extends Rsx_Site_Model_Abstract
|
||||||
{
|
{
|
||||||
/** __AUTO_GENERATED: */
|
/**
|
||||||
|
* _AUTO_GENERATED_ Enum constants
|
||||||
|
*/
|
||||||
const FILE_TYPE_IMAGE = 1;
|
const FILE_TYPE_IMAGE = 1;
|
||||||
const FILE_TYPE_ANIMATED_IMAGE = 2;
|
const FILE_TYPE_ANIMATED_IMAGE = 2;
|
||||||
const FILE_TYPE_VIDEO = 3;
|
const FILE_TYPE_VIDEO = 3;
|
||||||
@@ -73,6 +82,9 @@ class File_Attachment_Model extends Rsx_Site_Model_Abstract
|
|||||||
const FILE_TYPE_TEXT = 5;
|
const FILE_TYPE_TEXT = 5;
|
||||||
const FILE_TYPE_DOCUMENT = 6;
|
const FILE_TYPE_DOCUMENT = 6;
|
||||||
const FILE_TYPE_OTHER = 7;
|
const FILE_TYPE_OTHER = 7;
|
||||||
|
|
||||||
|
/** __AUTO_GENERATED: */
|
||||||
|
|
||||||
/** __/AUTO_GENERATED */
|
/** __/AUTO_GENERATED */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ use App\RSpade\Core\Database\Models\Rsx_Model_Abstract;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* Generated on: 2025-11-04 07:18:11
|
* Generated on: 2025-12-10 02:59:31
|
||||||
* Table: file_storage
|
* Table: _file_storage
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property mixed $hash
|
* @property mixed $hash
|
||||||
@@ -30,7 +30,7 @@ use App\RSpade\Core\Database\Models\Rsx_Model_Abstract;
|
|||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class File_Storage_Model extends Rsx_Model_Abstract
|
class File_Storage_Model extends Rsx_Model_Abstract
|
||||||
{
|
{
|
||||||
// Required static properties from parent abstract class
|
// Required static properties from parent abstract class
|
||||||
public static $enums = [];
|
public static $enums = [];
|
||||||
public static $rel = [];
|
public static $rel = [];
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use App\RSpade\Core\Models\Region_Model;
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* Generated on: 2025-11-04 07:18:11
|
* Generated on: 2025-12-10 02:59:31
|
||||||
* Table: countries
|
* Table: countries
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -32,7 +32,7 @@ use App\RSpade\Core\Models\Region_Model;
|
|||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Country_Model extends Rsx_Model_Abstract
|
class Country_Model extends Rsx_Model_Abstract
|
||||||
{
|
{
|
||||||
public static $enums = [];
|
public static $enums = [];
|
||||||
|
|
||||||
protected $table = 'countries';
|
protected $table = 'countries';
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use App\RSpade\Core\Database\Models\Rsx_System_Model_Abstract;
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* Generated on: 2025-11-04 07:18:11
|
* Generated on: 2025-12-10 02:59:31
|
||||||
* Table: ip_addresses
|
* Table: ip_addresses
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -30,7 +30,7 @@ use App\RSpade\Core\Database\Models\Rsx_System_Model_Abstract;
|
|||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Ip_Address_Model extends Rsx_System_Model_Abstract
|
class Ip_Address_Model extends Rsx_System_Model_Abstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Enum field definitions
|
* Enum field definitions
|
||||||
* @var array
|
* @var array
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use App\RSpade\Core\Session\Session;
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* Generated on: 2025-11-04 07:18:11
|
* Generated on: 2025-12-10 02:59:31
|
||||||
* Table: login_users
|
* Table: login_users
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -47,12 +47,14 @@ use App\RSpade\Core\Session\Session;
|
|||||||
* @property-read string $is_verified_constant
|
* @property-read string $is_verified_constant
|
||||||
* @property-read array $is_verified_enum_val
|
* @property-read array $is_verified_enum_val
|
||||||
*
|
*
|
||||||
* @method static array status_id_enum()
|
* @method static array status_id_enum_val() Get all enum definitions with full metadata
|
||||||
* @method static array status_id_enum_select()
|
* @method static array status_id_enum_select() Get selectable items for dropdowns
|
||||||
* @method static array status_id_enum_ids()
|
* @method static array status_id_enum_labels() Get simple id => label map
|
||||||
* @method static array is_verified_enum()
|
* @method static array status_id_enum_ids() Get array of all valid enum IDs
|
||||||
* @method static array is_verified_enum_select()
|
* @method static array is_verified_enum_val() Get all enum definitions with full metadata
|
||||||
* @method static array is_verified_enum_ids()
|
* @method static array is_verified_enum_select() Get selectable items for dropdowns
|
||||||
|
* @method static array is_verified_enum_labels() Get simple id => label map
|
||||||
|
* @method static array is_verified_enum_ids() Get array of all valid enum IDs
|
||||||
*
|
*
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
@@ -60,7 +62,7 @@ class Login_User_Model extends Rsx_Model_Abstract implements
|
|||||||
\Illuminate\Contracts\Auth\Authenticatable,
|
\Illuminate\Contracts\Auth\Authenticatable,
|
||||||
\Illuminate\Contracts\Auth\Access\Authorizable,
|
\Illuminate\Contracts\Auth\Access\Authorizable,
|
||||||
\Illuminate\Contracts\Auth\CanResetPassword
|
\Illuminate\Contracts\Auth\CanResetPassword
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_ Enum constants
|
* _AUTO_GENERATED_ Enum constants
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use App\RSpade\Core\Models\Country_Model;
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* Generated on: 2025-11-04 07:18:11
|
* Generated on: 2025-12-10 02:59:32
|
||||||
* Table: regions
|
* Table: regions
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -31,7 +31,7 @@ use App\RSpade\Core\Models\Country_Model;
|
|||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Region_Model extends Rsx_Model_Abstract
|
class Region_Model extends Rsx_Model_Abstract
|
||||||
{
|
{
|
||||||
public static $enums = [];
|
public static $enums = [];
|
||||||
|
|
||||||
protected $table = 'regions';
|
protected $table = 'regions';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use App\RSpade\Core\Models\User_Model;
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* Generated on: 2025-11-04 07:18:11
|
* Generated on: 2025-12-10 02:59:32
|
||||||
* Table: sites
|
* Table: sites
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -31,7 +31,7 @@ use App\RSpade\Core\Models\User_Model;
|
|||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Site_Model extends Rsx_Model_Abstract
|
class Site_Model extends Rsx_Model_Abstract
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use App\RSpade\Core\Database\Models\Rsx_Site_Model_Abstract;
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* Generated on: 2025-11-04 07:18:11
|
* Generated on: 2025-12-10 02:59:32
|
||||||
* Table: user_invites
|
* Table: user_invites
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -28,7 +28,7 @@ use App\RSpade\Core\Database\Models\Rsx_Site_Model_Abstract;
|
|||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class User_Invite_Model extends Rsx_Site_Model_Abstract
|
class User_Invite_Model extends Rsx_Site_Model_Abstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Enum field definitions
|
* Enum field definitions
|
||||||
* @var array
|
* @var array
|
||||||
|
|||||||
@@ -23,41 +23,47 @@ use App\RSpade\Core\Models\User_Profile_Model;
|
|||||||
* See: php artisan rsx:man acls
|
* See: php artisan rsx:man acls
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* @property integer $id
|
* Generated on: 2025-12-10 02:59:32
|
||||||
* @property integer $login_user_id
|
* Table: users
|
||||||
* @property integer $site_id
|
*
|
||||||
* @property string $first_name
|
* @property int $id
|
||||||
* @property string $last_name
|
* @property int $login_user_id
|
||||||
* @property string $phone
|
* @property int $site_id
|
||||||
* @property integer $role_id
|
* @property mixed $first_name
|
||||||
* @property boolean $is_enabled
|
* @property mixed $last_name
|
||||||
* @property integer $user_role_id
|
* @property mixed $phone
|
||||||
* @property string $email
|
* @property int $role_id
|
||||||
* @property \Carbon\Carbon $deleted_at
|
* @property bool $is_enabled
|
||||||
* @property \Carbon\Carbon $created_at
|
* @property int $user_role_id
|
||||||
* @property \Carbon\Carbon $updated_at
|
* @property mixed $email
|
||||||
* @property integer $created_by
|
* @property string $deleted_at
|
||||||
* @property integer $updated_by
|
* @property string $created_at
|
||||||
* @property integer $deleted_by
|
* @property string $updated_at
|
||||||
* @property string $invite_code
|
* @property int $created_by
|
||||||
* @property \Carbon\Carbon $invite_accepted_at
|
* @property int $updated_by
|
||||||
* @property \Carbon\Carbon $invite_expires_at
|
* @property int $deleted_by
|
||||||
* @method static mixed role_id_enum()
|
* @property mixed $invite_code
|
||||||
* @method static mixed role_id_enum_select()
|
* @property string $invite_accepted_at
|
||||||
* @method static mixed role_id_enum_ids()
|
* @property string $invite_expires_at
|
||||||
* @property-read mixed $role_id_constant
|
*
|
||||||
* @property-read mixed $role_id_label
|
* @property-read string $role_id_label
|
||||||
* @property-read mixed $role_id_permissions
|
* @property-read string $role_id_constant
|
||||||
* @property-read mixed $role_id_can_admin_roles
|
* @property-read array $role_id_enum_val
|
||||||
* @property-read mixed $role_id_selectable
|
*
|
||||||
|
* @method static array role_id_enum_val() Get all enum definitions with full metadata
|
||||||
|
* @method static array role_id_enum_select() Get selectable items for dropdowns
|
||||||
|
* @method static array role_id_enum_labels() Get simple id => label map
|
||||||
|
* @method static array role_id_enum_ids() Get array of all valid enum IDs
|
||||||
|
*
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class User_Model extends Rsx_Site_Model_Abstract
|
class User_Model extends Rsx_Site_Model_Abstract
|
||||||
{
|
{
|
||||||
/** __AUTO_GENERATED: */
|
/**
|
||||||
|
* _AUTO_GENERATED_ Enum constants
|
||||||
|
*/
|
||||||
const ROLE_DEVELOPER = 100;
|
const ROLE_DEVELOPER = 100;
|
||||||
const ROLE_ROOT_ADMIN = 200;
|
const ROLE_ROOT_ADMIN = 200;
|
||||||
const ROLE_SITE_OWNER = 300;
|
const ROLE_SITE_OWNER = 300;
|
||||||
@@ -66,6 +72,9 @@ class User_Model extends Rsx_Site_Model_Abstract
|
|||||||
const ROLE_USER = 600;
|
const ROLE_USER = 600;
|
||||||
const ROLE_VIEWER = 700;
|
const ROLE_VIEWER = 700;
|
||||||
const ROLE_DISABLED = 800;
|
const ROLE_DISABLED = 800;
|
||||||
|
|
||||||
|
/** __AUTO_GENERATED: */
|
||||||
|
|
||||||
/** __/AUTO_GENERATED */
|
/** __/AUTO_GENERATED */
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|||||||
@@ -6,17 +6,23 @@ use App\RSpade\Core\Database\Models\Rsx_Model_Abstract;
|
|||||||
use App\RSpade\Core\Models\User_Model;
|
use App\RSpade\Core\Models\User_Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* @property integer $id
|
* Generated on: 2025-12-10 02:59:32
|
||||||
* @property integer $user_id
|
* Table: user_permissions
|
||||||
* @property integer $permission_id
|
*
|
||||||
* @property boolean $is_grant
|
* @property int $id
|
||||||
* @property \Carbon\Carbon $created_at
|
* @property int $user_id
|
||||||
* @property \Carbon\Carbon $updated_at
|
* @property int $permission_id
|
||||||
|
* @property bool $is_grant
|
||||||
|
* @property string $created_at
|
||||||
|
* @property string $updated_at
|
||||||
|
* @property int $created_by
|
||||||
|
* @property int $updated_by
|
||||||
|
*
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class User_Permission_Model extends Rsx_Model_Abstract
|
class User_Permission_Model extends Rsx_Model_Abstract
|
||||||
{
|
{
|
||||||
protected $table = 'user_permissions';
|
protected $table = 'user_permissions';
|
||||||
protected $fillable = []; // No mass assignment - always explicit
|
protected $fillable = []; // No mass assignment - always explicit
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ use App\RSpade\Core\Models\User_Model;
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* Generated on: 2025-11-04 07:18:11
|
* Generated on: 2025-12-10 02:59:32
|
||||||
* Table: user_profiles
|
* Table: user_profiles
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -51,7 +51,7 @@ use App\RSpade\Core\Models\User_Model;
|
|||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class User_Profile_Model extends Rsx_Model_Abstract
|
class User_Profile_Model extends Rsx_Model_Abstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The table associated with the model
|
* The table associated with the model
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,33 +11,45 @@ use App\RSpade\Core\Database\Models\Rsx_Model_Abstract;
|
|||||||
* and two-factor authentication via email or SMS.
|
* and two-factor authentication via email or SMS.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* @property integer $id
|
* Generated on: 2025-12-10 02:59:32
|
||||||
* @property string $email
|
* Table: user_verifications
|
||||||
* @property string $verification_code
|
*
|
||||||
* @property integer $verification_type_id
|
* @property int $id
|
||||||
* @property \Carbon\Carbon $verified_at
|
* @property mixed $email
|
||||||
* @property \Carbon\Carbon $expires_at
|
* @property mixed $verification_code
|
||||||
* @property \Carbon\Carbon $created_at
|
* @property int $verification_type_id
|
||||||
* @property \Carbon\Carbon $updated_at
|
* @property string $verified_at
|
||||||
* @property integer $created_by
|
* @property string $expires_at
|
||||||
* @property integer $updated_by
|
* @property string $created_at
|
||||||
* @method static mixed verification_type_id_enum()
|
* @property string $updated_at
|
||||||
* @method static mixed verification_type_id_enum_select()
|
* @property int $created_by
|
||||||
* @method static mixed verification_type_id_enum_ids()
|
* @property int $updated_by
|
||||||
* @property-read mixed $verification_type_id_constant
|
*
|
||||||
* @property-read mixed $verification_type_id_label
|
* @property-read string $verification_type_id_label
|
||||||
|
* @property-read string $verification_type_id_constant
|
||||||
|
* @property-read array $verification_type_id_enum_val
|
||||||
|
*
|
||||||
|
* @method static array verification_type_id_enum_val() Get all enum definitions with full metadata
|
||||||
|
* @method static array verification_type_id_enum_select() Get selectable items for dropdowns
|
||||||
|
* @method static array verification_type_id_enum_labels() Get simple id => label map
|
||||||
|
* @method static array verification_type_id_enum_ids() Get array of all valid enum IDs
|
||||||
|
*
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class User_Verification_Model extends Rsx_Model_Abstract
|
class User_Verification_Model extends Rsx_Model_Abstract
|
||||||
{
|
{
|
||||||
/** __AUTO_GENERATED: */
|
/**
|
||||||
|
* _AUTO_GENERATED_ Enum constants
|
||||||
|
*/
|
||||||
const VERIFICATION_TYPE_EMAIL = 1;
|
const VERIFICATION_TYPE_EMAIL = 1;
|
||||||
const VERIFICATION_TYPE_SMS = 2;
|
const VERIFICATION_TYPE_SMS = 2;
|
||||||
const VERIFICATION_TYPE_EMAIL_RECOVERY = 3;
|
const VERIFICATION_TYPE_EMAIL_RECOVERY = 3;
|
||||||
const VERIFICATION_TYPE_SMS_RECOVERY = 4;
|
const VERIFICATION_TYPE_SMS_RECOVERY = 4;
|
||||||
|
|
||||||
|
/** __AUTO_GENERATED: */
|
||||||
|
|
||||||
/** __/AUTO_GENERATED */
|
/** __/AUTO_GENERATED */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ use App\RSpade\Core\Database\Models\Rsx_Site_Model_Abstract;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* Generated on: 2025-11-04 07:18:11
|
* Generated on: 2025-12-10 02:59:32
|
||||||
* Table: search_indexes
|
* Table: _search_indexes
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property mixed $indexable_type
|
* @property mixed $indexable_type
|
||||||
@@ -37,7 +37,7 @@ use App\RSpade\Core\Database\Models\Rsx_Site_Model_Abstract;
|
|||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Search_Index_Model extends Rsx_Site_Model_Abstract
|
class Search_Index_Model extends Rsx_Site_Model_Abstract
|
||||||
{
|
{
|
||||||
// Required static properties from parent abstract class
|
// Required static properties from parent abstract class
|
||||||
public static $enums = [];
|
public static $enums = [];
|
||||||
public static $rel = [];
|
public static $rel = [];
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ use App\RSpade\Core\Models\User_Model;
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* Generated on: 2025-11-04 07:18:11
|
* Generated on: 2025-12-10 02:59:33
|
||||||
* Table: sessions
|
* Table: _sessions
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property bool $active
|
* @property bool $active
|
||||||
@@ -62,7 +62,7 @@ use App\RSpade\Core\Models\User_Model;
|
|||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Session extends Rsx_System_Model_Abstract
|
class Session extends Rsx_System_Model_Abstract
|
||||||
{
|
{
|
||||||
// Enum definitions (required by abstract parent)
|
// Enum definitions (required by abstract parent)
|
||||||
public static $enums = [];
|
public static $enums = [];
|
||||||
|
|
||||||
|
|||||||
@@ -5,29 +5,42 @@ namespace App\RSpade\Lib\Flash;
|
|||||||
use App\RSpade\Core\Database\Models\Rsx_Model_Abstract;
|
use App\RSpade\Core\Database\Models\Rsx_Model_Abstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _AUTO_GENERATED_
|
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||||
* @property integer $id
|
* Generated on: 2025-12-10 02:59:33
|
||||||
* @property integer $session_id
|
* Table: _flash_alerts
|
||||||
* @property integer $type_id
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property int $session_id
|
||||||
|
* @property int $type_id
|
||||||
* @property string $message
|
* @property string $message
|
||||||
* @property \Carbon\Carbon $created_at
|
* @property string $created_at
|
||||||
* @property integer $created_by
|
* @property int $created_by
|
||||||
* @property integer $updated_by
|
* @property int $updated_by
|
||||||
* @property \Carbon\Carbon $updated_at
|
* @property string $updated_at
|
||||||
* @method static mixed type_id_enum()
|
*
|
||||||
* @method static mixed type_id_enum_select()
|
* @property-read string $type_id_label
|
||||||
* @method static mixed type_id_enum_ids()
|
* @property-read string $type_id_constant
|
||||||
* @property-read mixed $type_id_constant
|
* @property-read array $type_id_enum_val
|
||||||
* @property-read mixed $type_id_label
|
*
|
||||||
|
* @method static array type_id_enum_val() Get all enum definitions with full metadata
|
||||||
|
* @method static array type_id_enum_select() Get selectable items for dropdowns
|
||||||
|
* @method static array type_id_enum_labels() Get simple id => label map
|
||||||
|
* @method static array type_id_enum_ids() Get array of all valid enum IDs
|
||||||
|
*
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Flash_Alert_Model extends Rsx_Model_Abstract
|
class Flash_Alert_Model extends Rsx_Model_Abstract
|
||||||
{
|
{
|
||||||
/** __AUTO_GENERATED: */
|
/**
|
||||||
|
* _AUTO_GENERATED_ Enum constants
|
||||||
|
*/
|
||||||
const TYPE_SUCCESS = 1;
|
const TYPE_SUCCESS = 1;
|
||||||
const TYPE_ERROR = 2;
|
const TYPE_ERROR = 2;
|
||||||
const TYPE_INFO = 3;
|
const TYPE_INFO = 3;
|
||||||
const TYPE_WARNING = 4;
|
const TYPE_WARNING = 4;
|
||||||
|
|
||||||
|
/** __AUTO_GENERATED: */
|
||||||
|
|
||||||
/** __/AUTO_GENERATED */
|
/** __/AUTO_GENERATED */
|
||||||
|
|
||||||
// Enum constants (auto-generated by rsx:migrate:document_models)
|
// Enum constants (auto-generated by rsx:migrate:document_models)
|
||||||
|
|||||||
@@ -73,26 +73,47 @@ PHP MAGIC PROPERTIES (Instance)
|
|||||||
echo $user->status_badge; // "bg-success"
|
echo $user->status_badge; // "bg-success"
|
||||||
echo $user->status_visible_frontend; // true
|
echo $user->status_visible_frontend; // true
|
||||||
|
|
||||||
PHP STATIC METHODS
|
STATIC METHODS (PHP and JavaScript)
|
||||||
|
|
||||||
Model::field_enum()
|
These four methods are available as static methods on model classes in both PHP
|
||||||
Returns all enum definitions for a field with all properties:
|
and JavaScript. The JavaScript stubs are auto-generated to mirror PHP behavior.
|
||||||
|
|
||||||
$statuses = User_Model::status_id_enum();
|
Model::field_enum_val()
|
||||||
|
Returns all enum definitions for a field with full metadata:
|
||||||
|
|
||||||
|
$statuses = User_Model::status_id_enum_val();
|
||||||
// [1 => ['constant' => 'STATUS_ACTIVE', 'label' => 'Active', ...], ...]
|
// [1 => ['constant' => 'STATUS_ACTIVE', 'label' => 'Active', ...], ...]
|
||||||
|
|
||||||
|
// JavaScript equivalent:
|
||||||
|
const statuses = User_Model.status_id_enum_val();
|
||||||
|
|
||||||
Model::field_enum_select()
|
Model::field_enum_select()
|
||||||
Returns key/label pairs for dropdowns, respecting 'selectable' and 'order':
|
Returns selectable items for dropdowns (respects 'selectable' and 'order'):
|
||||||
|
|
||||||
$options = User_Model::status_id_enum_select();
|
$options = User_Model::status_id_enum_select();
|
||||||
// [1 => 'Active', 2 => 'Inactive']
|
// [1 => 'Active', 2 => 'Inactive'] (excludes selectable: false items)
|
||||||
|
|
||||||
|
// JavaScript equivalent:
|
||||||
|
const options = User_Model.status_id_enum_select();
|
||||||
|
|
||||||
|
Model::field_enum_labels()
|
||||||
|
Returns simple id => label map (all items, ignores selectable flag):
|
||||||
|
|
||||||
|
$labels = User_Model::status_id_enum_labels();
|
||||||
|
// [1 => 'Active', 2 => 'Inactive', 3 => 'Archived']
|
||||||
|
|
||||||
|
// JavaScript equivalent:
|
||||||
|
const labels = User_Model.status_id_enum_labels();
|
||||||
|
|
||||||
Model::field_enum_ids()
|
Model::field_enum_ids()
|
||||||
Returns all possible enum values as an array:
|
Returns array of all valid enum IDs:
|
||||||
|
|
||||||
$ids = User_Model::status_id_enum_ids();
|
$ids = User_Model::status_id_enum_ids();
|
||||||
// [1, 2, 3]
|
// [1, 2, 3]
|
||||||
|
|
||||||
|
// JavaScript equivalent:
|
||||||
|
const ids = User_Model.status_id_enum_ids();
|
||||||
|
|
||||||
PHP CONSTANTS
|
PHP CONSTANTS
|
||||||
|
|
||||||
Constants are automatically generated via rsx:migrate:document_models command:
|
Constants are automatically generated via rsx:migrate:document_models command:
|
||||||
@@ -117,10 +138,11 @@ JAVASCRIPT ACCESS
|
|||||||
Project_Model.STATUS_ACTIVE // 2
|
Project_Model.STATUS_ACTIVE // 2
|
||||||
Project_Model.STATUS_PLANNING // 1
|
Project_Model.STATUS_PLANNING // 1
|
||||||
|
|
||||||
Static Methods
|
Static Methods (same as PHP - see STATIC METHODS section above)
|
||||||
Project_Model.status_enum_val() // Full enum definitions
|
Project_Model.status_enum_val() // Full enum definitions with metadata
|
||||||
Project_Model.status_enum_select() // Filtered for dropdowns
|
Project_Model.status_enum_select() // Selectable items for dropdowns
|
||||||
Project_Model.status_label_list() // All labels keyed by value
|
Project_Model.status_enum_labels() // Simple id => label map
|
||||||
|
Project_Model.status_enum_ids() // Array of valid IDs
|
||||||
|
|
||||||
Instance Properties (after fetch)
|
Instance Properties (after fetch)
|
||||||
const project = await Project_Model.fetch(1);
|
const project = await Project_Model.fetch(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user