createTable('dashboard_widgets', function($table) { $table->bigInteger('id')->autoIncrement()->notNull() ->string('widget_id', 100)->notNull()->comment('Unique widget identifier') ->string('module_name', 100)->notNull()->comment('Module that provides this widget') ->string('widget_name', 255)->notNull()->comment('Display name of widget') ->text('widget_description')->nullable()->comment('Widget description') ->string('widget_class', 255)->notNull()->comment('PHP class that renders the widget') ->string('widget_method', 100)->default('render')->comment('Method to call for rendering') ->json('default_config')->nullable()->comment('Default widget configuration') ->string('widget_size', 20)->default('medium')->comment('small, medium, large, full') ->string('widget_category', 100)->default('general')->comment('Widget category for organization') ->tinyInteger('is_active')->default(1)->notNull()->comment('1=active, 0=inactive') ->timestamp('created_at')->default('CURRENT_TIMESTAMP')->notNull() ->timestamp('updated_at')->default('CURRENT_TIMESTAMP')->notNull() ->primaryKey('id') ->unique('widget_id') ->index('module_name') ->index('widget_category') ->index('is_active'); }); // Create user_dashboard_widgets table - User's personalized dashboard $this->createTable('user_dashboard_widgets', function($table) { $table->bigInteger('id')->autoIncrement()->notNull() ->bigInteger('user_id')->notNull()->comment('User who owns this dashboard configuration') ->string('widget_id', 100)->notNull()->comment('Reference to dashboard_widgets.widget_id') ->integer('position_order')->default(0)->comment('Display order on dashboard') ->string('widget_size', 20)->nullable()->comment('User override for widget size') ->json('widget_config')->nullable()->comment('User-specific widget configuration') ->tinyInteger('is_visible')->default(1)->notNull()->comment('1=visible, 0=hidden') ->timestamp('created_at')->default('CURRENT_TIMESTAMP')->notNull() ->timestamp('updated_at')->default('CURRENT_TIMESTAMP')->notNull() ->primaryKey('id') ->uniqueComposite('uk_user_widget', ['user_id', 'widget_id']) ->index('user_id') ->index('position_order') ->index('is_visible'); }); echo "Created dashboard widgets system tables\n"; } /** * Reverse the migration */ public function down(): void { $this->dropTable('user_dashboard_widgets'); $this->dropTable('dashboard_widgets'); echo "Removed dashboard widgets system tables\n"; } /** * Get migration description */ public function getDescription(): string { return 'Create dashboard widgets system for modular customizable dashboard'; } }