Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

2024_01_01_234943_create_transactions_table.php 1.5KB

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('category_id')->nullable()->constrained()->nullOnDelete();
  16. $table->foreignId('contact_id')->nullable()->constrained()->nullOnDelete();
  17. $table->string('type'); // income, expense, other
  18. $table->string('method'); // deposit, withdrawal
  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. };