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)) {
|
||||
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}_constant";
|
||||
$enumProperties[] = " * @property-read array \${$columnName}_enum_val";
|
||||
|
||||
// Add enum static methods
|
||||
$enumMethods[] = " * @method static array {$columnName}_enum()";
|
||||
$enumMethods[] = " * @method static array {$columnName}_enum_select()";
|
||||
$enumMethods[] = " * @method static array {$columnName}_enum_ids()";
|
||||
// Add enum static methods (mirrored in JavaScript stubs)
|
||||
$enumMethods[] = " * @method static array {$columnName}_enum_val() Get all enum definitions with full metadata";
|
||||
$enumMethods[] = " * @method static array {$columnName}_enum_select() Get selectable items for dropdowns";
|
||||
$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
|
||||
foreach ($enumDefinitions as $value => $definition) {
|
||||
|
||||
@@ -31,8 +31,29 @@ use App\RSpade\Core\Models\User_Model;
|
||||
* @property \Carbon\Carbon $created_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
|
||||
{
|
||||
{
|
||||
protected $table = '_api_keys';
|
||||
|
||||
public static $enums = [];
|
||||
|
||||
@@ -383,21 +383,7 @@ class Database_BundleIntegration extends BundleIntegration_Abstract
|
||||
$content .= " });\n";
|
||||
$content .= " }\n\n";
|
||||
|
||||
// Generate enum label list
|
||||
$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
|
||||
// Generate enum_select() - Selectable items for dropdowns (respects selectable: false)
|
||||
$content .= " static {$column}_enum_select() {\n";
|
||||
$content .= " const fullData = this.{$column}_enum_val();\n";
|
||||
$content .= " const data = {};\n";
|
||||
@@ -428,6 +414,27 @@ class Database_BundleIntegration extends BundleIntegration_Abstract
|
||||
$content .= " }\n";
|
||||
$content .= " });\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
|
||||
|
||||
@@ -40,9 +40,13 @@ use RuntimeException;
|
||||
* This provides magic properties and methods:
|
||||
* - $model->status_label - Get label for current enum value
|
||||
* - $model->status_constant - Get constant name for current value
|
||||
* - Model::status_enum() - Get all enum definitions
|
||||
* - Model::status_enum_select() - Get key/label pairs for dropdowns
|
||||
* - Model::status_enum_ids() - Get all possible enum values
|
||||
* - $model->status_enum_val - Get all properties for current value
|
||||
*
|
||||
* 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]
|
||||
#[Instantiatable]
|
||||
@@ -82,10 +86,11 @@ abstract class Rsx_Model_Abstract extends Model
|
||||
/**
|
||||
* Private helper to resolve enum magic properties and methods
|
||||
*
|
||||
* Handles:
|
||||
* - field_enum() - Returns all enum definitions for a field
|
||||
* - field_enum_select() - Returns key/label pairs for dropdowns
|
||||
* - field_enum_ids() - Returns all possible enum values
|
||||
* Handles (these are mirrored in JavaScript stubs):
|
||||
* - field_enum_val() - Returns all enum definitions with full metadata
|
||||
* - field_enum_select() - Returns selectable items for dropdowns
|
||||
* - 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 mixed $value Optional value for filtering selectable items
|
||||
@@ -114,10 +119,12 @@ abstract class Rsx_Model_Abstract extends Model
|
||||
return $keyA <=> $keyB;
|
||||
});
|
||||
|
||||
if ($key == $column . '_enum') {
|
||||
// field_enum_val() - All enum definitions with full metadata
|
||||
if ($key == $column . '_enum_val') {
|
||||
return $sorted_config;
|
||||
}
|
||||
|
||||
// field_enum_select() - Selectable items for dropdowns (respects selectable: false)
|
||||
if ($key == $column . '_enum_select') {
|
||||
$return = [];
|
||||
|
||||
@@ -133,6 +140,18 @@ abstract class Rsx_Model_Abstract extends Model
|
||||
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') {
|
||||
return array_keys($sorted_config);
|
||||
}
|
||||
@@ -228,10 +247,11 @@ abstract class Rsx_Model_Abstract extends Model
|
||||
/**
|
||||
* Magic static method handler for enum methods
|
||||
*
|
||||
* Provides static access to:
|
||||
* - Model::field_enum() - All enum definitions
|
||||
* - Model::field_enum_select() - Key/label pairs for dropdowns
|
||||
* - Model::field_enum_ids() - All possible enum values
|
||||
* Provides static access to (mirrored in JavaScript stubs):
|
||||
* - Model::field_enum_val() - All enum definitions with full metadata
|
||||
* - Model::field_enum_select() - Selectable items for dropdowns
|
||||
* - Model::field_enum_labels() - Simple id => label map
|
||||
* - Model::field_enum_ids() - Array of all valid enum IDs
|
||||
*
|
||||
* @param string $key
|
||||
* @param array $args
|
||||
|
||||
@@ -30,42 +30,51 @@ use App\RSpade\Core\Files\File_Storage_Model;
|
||||
* provides the basic structure for categorizing uploaded files.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* _AUTO_GENERATED_
|
||||
* @property integer $id
|
||||
* @property string $key
|
||||
* @property integer $file_storage_id
|
||||
* @property string $file_name
|
||||
* @property string $file_extension
|
||||
* @property integer $file_type_id
|
||||
* @property integer $width
|
||||
* @property integer $height
|
||||
* @property integer $duration
|
||||
* @property boolean $is_animated
|
||||
* @property integer $frame_count
|
||||
* @property string $fileable_type
|
||||
* @property integer $fileable_id
|
||||
* @property string $fileable_category
|
||||
* @property string $fileable_type_meta
|
||||
* @property integer $fileable_order
|
||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||
* Generated on: 2025-12-10 02:59:31
|
||||
* Table: _file_attachments
|
||||
*
|
||||
* @property int $id
|
||||
* @property mixed $key
|
||||
* @property int $file_storage_id
|
||||
* @property mixed $file_name
|
||||
* @property mixed $file_extension
|
||||
* @property int $file_type_id
|
||||
* @property int $width
|
||||
* @property int $height
|
||||
* @property int $duration
|
||||
* @property bool $is_animated
|
||||
* @property int $frame_count
|
||||
* @property mixed $fileable_type
|
||||
* @property int $fileable_id
|
||||
* @property mixed $fileable_category
|
||||
* @property mixed $fileable_type_meta
|
||||
* @property int $fileable_order
|
||||
* @property string $fileable_meta
|
||||
* @property integer $site_id
|
||||
* @property string $session_id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $created_by
|
||||
* @property integer $updated_by
|
||||
* @method static mixed file_type_id_enum()
|
||||
* @method static mixed file_type_id_enum_select()
|
||||
* @method static mixed file_type_id_enum_ids()
|
||||
* @property-read mixed $file_type_id_constant
|
||||
* @property-read mixed $file_type_id_label
|
||||
* @property int $site_id
|
||||
* @property mixed $session_id
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property int $created_by
|
||||
* @property int $updated_by
|
||||
*
|
||||
* @property-read string $file_type_id_label
|
||||
* @property-read string $file_type_id_constant
|
||||
* @property-read array $file_type_id_enum_val
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
class File_Attachment_Model extends Rsx_Site_Model_Abstract
|
||||
{
|
||||
/** __AUTO_GENERATED: */
|
||||
{
|
||||
/**
|
||||
* _AUTO_GENERATED_ Enum constants
|
||||
*/
|
||||
const FILE_TYPE_IMAGE = 1;
|
||||
const FILE_TYPE_ANIMATED_IMAGE = 2;
|
||||
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_DOCUMENT = 6;
|
||||
const FILE_TYPE_OTHER = 7;
|
||||
|
||||
/** __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
|
||||
* Generated on: 2025-11-04 07:18:11
|
||||
* Table: file_storage
|
||||
* Generated on: 2025-12-10 02:59:31
|
||||
* Table: _file_storage
|
||||
*
|
||||
* @property int $id
|
||||
* @property mixed $hash
|
||||
@@ -30,7 +30,7 @@ use App\RSpade\Core\Database\Models\Rsx_Model_Abstract;
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class File_Storage_Model extends Rsx_Model_Abstract
|
||||
{
|
||||
{
|
||||
// Required static properties from parent abstract class
|
||||
public static $enums = [];
|
||||
public static $rel = [];
|
||||
|
||||
@@ -14,7 +14,7 @@ use App\RSpade\Core\Models\Region_Model;
|
||||
*/
|
||||
/**
|
||||
* _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
|
||||
*
|
||||
* @property int $id
|
||||
@@ -32,7 +32,7 @@ use App\RSpade\Core\Models\Region_Model;
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Country_Model extends Rsx_Model_Abstract
|
||||
{
|
||||
{
|
||||
public static $enums = [];
|
||||
|
||||
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
|
||||
* Generated on: 2025-11-04 07:18:11
|
||||
* Generated on: 2025-12-10 02:59:31
|
||||
* Table: ip_addresses
|
||||
*
|
||||
* @property int $id
|
||||
@@ -30,7 +30,7 @@ use App\RSpade\Core\Database\Models\Rsx_System_Model_Abstract;
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Ip_Address_Model extends Rsx_System_Model_Abstract
|
||||
{
|
||||
{
|
||||
/**
|
||||
* Enum field definitions
|
||||
* @var array
|
||||
|
||||
@@ -24,7 +24,7 @@ use App\RSpade\Core\Session\Session;
|
||||
*/
|
||||
/**
|
||||
* _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
|
||||
*
|
||||
* @property int $id
|
||||
@@ -47,12 +47,14 @@ use App\RSpade\Core\Session\Session;
|
||||
* @property-read string $is_verified_constant
|
||||
* @property-read array $is_verified_enum_val
|
||||
*
|
||||
* @method static array status_id_enum()
|
||||
* @method static array status_id_enum_select()
|
||||
* @method static array status_id_enum_ids()
|
||||
* @method static array is_verified_enum()
|
||||
* @method static array is_verified_enum_select()
|
||||
* @method static array is_verified_enum_ids()
|
||||
* @method static array status_id_enum_val() Get all enum definitions with full metadata
|
||||
* @method static array status_id_enum_select() Get selectable items for dropdowns
|
||||
* @method static array status_id_enum_labels() Get simple id => label map
|
||||
* @method static array status_id_enum_ids() Get array of all valid enum IDs
|
||||
* @method static array is_verified_enum_val() Get all enum definitions with full metadata
|
||||
* @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
|
||||
*/
|
||||
@@ -60,7 +62,7 @@ class Login_User_Model extends Rsx_Model_Abstract implements
|
||||
\Illuminate\Contracts\Auth\Authenticatable,
|
||||
\Illuminate\Contracts\Auth\Access\Authorizable,
|
||||
\Illuminate\Contracts\Auth\CanResetPassword
|
||||
{
|
||||
{
|
||||
/**
|
||||
* _AUTO_GENERATED_ Enum constants
|
||||
*/
|
||||
|
||||
@@ -14,7 +14,7 @@ use App\RSpade\Core\Models\Country_Model;
|
||||
*/
|
||||
/**
|
||||
* _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
|
||||
*
|
||||
* @property int $id
|
||||
@@ -31,7 +31,7 @@ use App\RSpade\Core\Models\Country_Model;
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Region_Model extends Rsx_Model_Abstract
|
||||
{
|
||||
{
|
||||
public static $enums = [];
|
||||
|
||||
protected $table = 'regions';
|
||||
|
||||
@@ -14,7 +14,7 @@ use App\RSpade\Core\Models\User_Model;
|
||||
*/
|
||||
/**
|
||||
* _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
|
||||
*
|
||||
* @property int $id
|
||||
@@ -31,7 +31,7 @@ use App\RSpade\Core\Models\User_Model;
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Site_Model extends Rsx_Model_Abstract
|
||||
{
|
||||
{
|
||||
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
|
||||
* Generated on: 2025-11-04 07:18:11
|
||||
* Generated on: 2025-12-10 02:59:32
|
||||
* Table: user_invites
|
||||
*
|
||||
* @property int $id
|
||||
@@ -28,7 +28,7 @@ use App\RSpade\Core\Database\Models\Rsx_Site_Model_Abstract;
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User_Invite_Model extends Rsx_Site_Model_Abstract
|
||||
{
|
||||
{
|
||||
/**
|
||||
* Enum field definitions
|
||||
* @var array
|
||||
|
||||
@@ -23,41 +23,47 @@ use App\RSpade\Core\Models\User_Profile_Model;
|
||||
* See: php artisan rsx:man acls
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* _AUTO_GENERATED_
|
||||
* @property integer $id
|
||||
* @property integer $login_user_id
|
||||
* @property integer $site_id
|
||||
* @property string $first_name
|
||||
* @property string $last_name
|
||||
* @property string $phone
|
||||
* @property integer $role_id
|
||||
* @property boolean $is_enabled
|
||||
* @property integer $user_role_id
|
||||
* @property string $email
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $created_by
|
||||
* @property integer $updated_by
|
||||
* @property integer $deleted_by
|
||||
* @property string $invite_code
|
||||
* @property \Carbon\Carbon $invite_accepted_at
|
||||
* @property \Carbon\Carbon $invite_expires_at
|
||||
* @method static mixed role_id_enum()
|
||||
* @method static mixed role_id_enum_select()
|
||||
* @method static mixed role_id_enum_ids()
|
||||
* @property-read mixed $role_id_constant
|
||||
* @property-read mixed $role_id_label
|
||||
* @property-read mixed $role_id_permissions
|
||||
* @property-read mixed $role_id_can_admin_roles
|
||||
* @property-read mixed $role_id_selectable
|
||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||
* Generated on: 2025-12-10 02:59:32
|
||||
* Table: users
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $login_user_id
|
||||
* @property int $site_id
|
||||
* @property mixed $first_name
|
||||
* @property mixed $last_name
|
||||
* @property mixed $phone
|
||||
* @property int $role_id
|
||||
* @property bool $is_enabled
|
||||
* @property int $user_role_id
|
||||
* @property mixed $email
|
||||
* @property string $deleted_at
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property int $created_by
|
||||
* @property int $updated_by
|
||||
* @property int $deleted_by
|
||||
* @property mixed $invite_code
|
||||
* @property string $invite_accepted_at
|
||||
* @property string $invite_expires_at
|
||||
*
|
||||
* @property-read string $role_id_label
|
||||
* @property-read string $role_id_constant
|
||||
* @property-read array $role_id_enum_val
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
class User_Model extends Rsx_Site_Model_Abstract
|
||||
{
|
||||
/** __AUTO_GENERATED: */
|
||||
{
|
||||
/**
|
||||
* _AUTO_GENERATED_ Enum constants
|
||||
*/
|
||||
const ROLE_DEVELOPER = 100;
|
||||
const ROLE_ROOT_ADMIN = 200;
|
||||
const ROLE_SITE_OWNER = 300;
|
||||
@@ -66,6 +72,9 @@ class User_Model extends Rsx_Site_Model_Abstract
|
||||
const ROLE_USER = 600;
|
||||
const ROLE_VIEWER = 700;
|
||||
const ROLE_DISABLED = 800;
|
||||
|
||||
/** __AUTO_GENERATED: */
|
||||
|
||||
/** __/AUTO_GENERATED */
|
||||
|
||||
// =========================================================================
|
||||
|
||||
@@ -6,17 +6,23 @@ use App\RSpade\Core\Database\Models\Rsx_Model_Abstract;
|
||||
use App\RSpade\Core\Models\User_Model;
|
||||
|
||||
/**
|
||||
* _AUTO_GENERATED_
|
||||
* @property integer $id
|
||||
* @property integer $user_id
|
||||
* @property integer $permission_id
|
||||
* @property boolean $is_grant
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||
* Generated on: 2025-12-10 02:59:32
|
||||
* Table: user_permissions
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @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
|
||||
*/
|
||||
class User_Permission_Model extends Rsx_Model_Abstract
|
||||
{
|
||||
{
|
||||
protected $table = 'user_permissions';
|
||||
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
|
||||
* Generated on: 2025-11-04 07:18:11
|
||||
* Generated on: 2025-12-10 02:59:32
|
||||
* Table: user_profiles
|
||||
*
|
||||
* @property int $id
|
||||
@@ -51,7 +51,7 @@ use App\RSpade\Core\Models\User_Model;
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User_Profile_Model extends Rsx_Model_Abstract
|
||||
{
|
||||
{
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* _AUTO_GENERATED_
|
||||
* @property integer $id
|
||||
* @property string $email
|
||||
* @property string $verification_code
|
||||
* @property integer $verification_type_id
|
||||
* @property \Carbon\Carbon $verified_at
|
||||
* @property \Carbon\Carbon $expires_at
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $created_by
|
||||
* @property integer $updated_by
|
||||
* @method static mixed verification_type_id_enum()
|
||||
* @method static mixed verification_type_id_enum_select()
|
||||
* @method static mixed verification_type_id_enum_ids()
|
||||
* @property-read mixed $verification_type_id_constant
|
||||
* @property-read mixed $verification_type_id_label
|
||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||
* Generated on: 2025-12-10 02:59:32
|
||||
* Table: user_verifications
|
||||
*
|
||||
* @property int $id
|
||||
* @property mixed $email
|
||||
* @property mixed $verification_code
|
||||
* @property int $verification_type_id
|
||||
* @property string $verified_at
|
||||
* @property string $expires_at
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property int $created_by
|
||||
* @property int $updated_by
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
class User_Verification_Model extends Rsx_Model_Abstract
|
||||
{
|
||||
/** __AUTO_GENERATED: */
|
||||
{
|
||||
/**
|
||||
* _AUTO_GENERATED_ Enum constants
|
||||
*/
|
||||
const VERIFICATION_TYPE_EMAIL = 1;
|
||||
const VERIFICATION_TYPE_SMS = 2;
|
||||
const VERIFICATION_TYPE_EMAIL_RECOVERY = 3;
|
||||
const VERIFICATION_TYPE_SMS_RECOVERY = 4;
|
||||
|
||||
/** __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
|
||||
* Generated on: 2025-11-04 07:18:11
|
||||
* Table: search_indexes
|
||||
* Generated on: 2025-12-10 02:59:32
|
||||
* Table: _search_indexes
|
||||
*
|
||||
* @property int $id
|
||||
* @property mixed $indexable_type
|
||||
@@ -37,7 +37,7 @@ use App\RSpade\Core\Database\Models\Rsx_Site_Model_Abstract;
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Search_Index_Model extends Rsx_Site_Model_Abstract
|
||||
{
|
||||
{
|
||||
// Required static properties from parent abstract class
|
||||
public static $enums = [];
|
||||
public static $rel = [];
|
||||
|
||||
@@ -40,8 +40,8 @@ use App\RSpade\Core\Models\User_Model;
|
||||
*/
|
||||
/**
|
||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||
* Generated on: 2025-11-04 07:18:11
|
||||
* Table: sessions
|
||||
* Generated on: 2025-12-10 02:59:33
|
||||
* Table: _sessions
|
||||
*
|
||||
* @property int $id
|
||||
* @property bool $active
|
||||
@@ -62,7 +62,7 @@ use App\RSpade\Core\Models\User_Model;
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Session extends Rsx_System_Model_Abstract
|
||||
{
|
||||
{
|
||||
// Enum definitions (required by abstract parent)
|
||||
public static $enums = [];
|
||||
|
||||
|
||||
@@ -5,29 +5,42 @@ namespace App\RSpade\Lib\Flash;
|
||||
use App\RSpade\Core\Database\Models\Rsx_Model_Abstract;
|
||||
|
||||
/**
|
||||
* _AUTO_GENERATED_
|
||||
* @property integer $id
|
||||
* @property integer $session_id
|
||||
* @property integer $type_id
|
||||
* _AUTO_GENERATED_ Database type hints - do not edit manually
|
||||
* Generated on: 2025-12-10 02:59:33
|
||||
* Table: _flash_alerts
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $session_id
|
||||
* @property int $type_id
|
||||
* @property string $message
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property integer $created_by
|
||||
* @property integer $updated_by
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @method static mixed type_id_enum()
|
||||
* @method static mixed type_id_enum_select()
|
||||
* @method static mixed type_id_enum_ids()
|
||||
* @property-read mixed $type_id_constant
|
||||
* @property-read mixed $type_id_label
|
||||
* @property string $created_at
|
||||
* @property int $created_by
|
||||
* @property int $updated_by
|
||||
* @property string $updated_at
|
||||
*
|
||||
* @property-read string $type_id_label
|
||||
* @property-read string $type_id_constant
|
||||
* @property-read array $type_id_enum_val
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
class Flash_Alert_Model extends Rsx_Model_Abstract
|
||||
{
|
||||
/** __AUTO_GENERATED: */
|
||||
{
|
||||
/**
|
||||
* _AUTO_GENERATED_ Enum constants
|
||||
*/
|
||||
const TYPE_SUCCESS = 1;
|
||||
const TYPE_ERROR = 2;
|
||||
const TYPE_INFO = 3;
|
||||
const TYPE_WARNING = 4;
|
||||
|
||||
/** __AUTO_GENERATED: */
|
||||
|
||||
/** __/AUTO_GENERATED */
|
||||
|
||||
// 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_visible_frontend; // true
|
||||
|
||||
PHP STATIC METHODS
|
||||
STATIC METHODS (PHP and JavaScript)
|
||||
|
||||
Model::field_enum()
|
||||
Returns all enum definitions for a field with all properties:
|
||||
These four methods are available as static methods on model classes in both PHP
|
||||
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', ...], ...]
|
||||
|
||||
// JavaScript equivalent:
|
||||
const statuses = User_Model.status_id_enum_val();
|
||||
|
||||
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();
|
||||
// [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()
|
||||
Returns all possible enum values as an array:
|
||||
Returns array of all valid enum IDs:
|
||||
|
||||
$ids = User_Model::status_id_enum_ids();
|
||||
// [1, 2, 3]
|
||||
|
||||
// JavaScript equivalent:
|
||||
const ids = User_Model.status_id_enum_ids();
|
||||
|
||||
PHP CONSTANTS
|
||||
|
||||
Constants are automatically generated via rsx:migrate:document_models command:
|
||||
@@ -117,10 +138,11 @@ JAVASCRIPT ACCESS
|
||||
Project_Model.STATUS_ACTIVE // 2
|
||||
Project_Model.STATUS_PLANNING // 1
|
||||
|
||||
Static Methods
|
||||
Project_Model.status_enum_val() // Full enum definitions
|
||||
Project_Model.status_enum_select() // Filtered for dropdowns
|
||||
Project_Model.status_label_list() // All labels keyed by value
|
||||
Static Methods (same as PHP - see STATIC METHODS section above)
|
||||
Project_Model.status_enum_val() // Full enum definitions with metadata
|
||||
Project_Model.status_enum_select() // Selectable items for dropdowns
|
||||
Project_Model.status_enum_labels() // Simple id => label map
|
||||
Project_Model.status_enum_ids() // Array of valid IDs
|
||||
|
||||
Instance Properties (after fetch)
|
||||
const project = await Project_Model.fetch(1);
|
||||
|
||||
Reference in New Issue
Block a user