hasTable('cash_flow_categories')) { Capsule::schema()->create('cash_flow_categories', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('idbus')->nullable(); $table->unsignedBigInteger('iduser')->nullable(); $table->string('name'); $table->enum('type', ['income', 'expense']); $table->string('color')->default('#6c757d'); $table->string('icon')->default('bi bi-tag'); $table->boolean('is_active')->default(true); $table->timestamps(); $table->index('idbus'); $table->index('iduser'); }); } // Transações de Fluxo de Caixa if (!Capsule::schema()->hasTable('cash_flow_transactions')) { Capsule::schema()->create('cash_flow_transactions', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('idbus')->nullable(); $table->unsignedBigInteger('iduser')->nullable(); $table->unsignedBigInteger('category_id'); $table->string('description'); $table->decimal('amount', 15, 2); $table->enum('type', ['income', 'expense']); $table->enum('status', ['pending', 'paid', 'cancelled'])->default('pending'); $table->date('transaction_date'); $table->date('due_date')->nullable(); $table->date('payment_date')->nullable(); $table->boolean('is_personal')->default(false); $table->text('notes')->nullable(); $table->json('metadata')->nullable(); $table->timestamps(); $table->index('idbus'); $table->index('iduser'); $table->index('category_id'); $table->index('transaction_date'); }); } // Análises e Previsões (IA) if (!Capsule::schema()->hasTable('cash_flow_analysis')) { Capsule::schema()->create('cash_flow_analysis', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('idbus')->nullable(); $table->unsignedBigInteger('iduser')->nullable(); $table->date('analysis_date'); $table->json('summary_data'); $table->text('recommendations')->nullable(); $table->json('projections')->nullable(); $table->timestamps(); $table->index('idbus'); $table->index('iduser'); $table->index('analysis_date'); }); } } /** * Reverse the migrations. * * @return void */ public function down(): void { Capsule::schema()->dropIfExists('cash_flow_analysis'); Capsule::schema()->dropIfExists('cash_flow_transactions'); Capsule::schema()->dropIfExists('cash_flow_categories'); } }