You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2024_01_01_234943_create_transactions_table.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. */
  10. public function up(): void
  11. {
  12. Schema::create('transactions', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  15. $table->foreignId('account_id')->nullable()->constrained()->nullOnDelete();
  16. $table->foreignId('bank_account_id')->nullable()->constrained()->nullOnDelete();
  17. $table->foreignId('contact_id')->nullable()->constrained()->nullOnDelete();
  18. $table->string('type'); // deposit, withdrawal, journal
  19. $table->string('payment_channel')->nullable(); // online, in store, other
  20. $table->string('description')->nullable();
  21. $table->text('notes')->nullable();
  22. $table->string('reference')->nullable();
  23. $table->bigInteger('amount')->default(0);
  24. $table->boolean('pending')->default(false);
  25. $table->boolean('reviewed')->default(false);
  26. $table->dateTime('posted_at');
  27. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  28. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  29. $table->timestamps();
  30. });
  31. }
  32. /**
  33. * Reverse the migrations.
  34. */
  35. public function down(): void
  36. {
  37. Schema::dropIfExists('transactions');
  38. }
  39. };