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.

2023_05_21_163808_create_discounts_table.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  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('discounts', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  15. $table->string('name');
  16. $table->text('description')->nullable();
  17. $table->decimal('rate', 15, 4);
  18. $table->string('computation')->default('percentage'); // percentage, fixed
  19. $table->string('type')->default('sales'); // sales, purchases
  20. $table->string('scope')->nullable(); // product, service, none
  21. $table->dateTime('start_date')->nullable();
  22. $table->dateTime('end_date')->nullable();
  23. $table->boolean('enabled')->default(true);
  24. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  25. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  26. $table->timestamps();
  27. });
  28. }
  29. /**
  30. * Reverse the migrations.
  31. */
  32. public function down(): void
  33. {
  34. Schema::dropIfExists('discounts');
  35. }
  36. };