vernova/database/migrations/2024_01_01_000010_create_expenses_table.php
2026-07-26 19:58:27 +03:30

41 lines
1.5 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('expenses', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
$table->foreignId('project_id')->constrained()->cascadeOnDelete();
$table->foreignId('petty_cash_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('employee_id')->nullable()->constrained()->nullOnDelete();
$table->decimal('amount', 15, 0);
$table->foreignId('currency_id')->constrained('currencies')->cascadeOnDelete();
$table->decimal('original_amount', 15, 0)->nullable();
$table->text('description')->nullable();
$table->date('expense_date');
$table->string('category')->nullable();
$table->string('receipt_path')->nullable();
$table->enum('status', ['pending', 'approved', 'rejected'])->default('pending');
$table->foreignId('approved_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->softDeletes();
$table->index('tenant_id');
$table->index('project_id');
$table->index('status');
$table->index('expense_date');
});
}
public function down(): void
{
Schema::dropIfExists('expenses');
}
};