2017_06_13_053346_create_orders_table.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateOrdersTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('orders', function (Blueprint $table) {
  15. $table->increments('id');
  16. $table->string('reference')->unique();
  17. $table->integer('courier_id')->unsigned()->index();
  18. $table->foreign('courier_id')->references('id')->on('couriers');
  19. $table->integer('customer_id')->unsigned()->index();
  20. $table->foreign('customer_id')->references('id')->on('customers');
  21. $table->integer('address_id')->unsigned()->index();
  22. $table->foreign('address_id')->references('id')->on('addresses');
  23. $table->integer('order_status_id')->unsigned()->index();
  24. $table->foreign('order_status_id')->references('id')->on('order_statuses');
  25. $table->string('payment');
  26. $table->decimal('discounts')->default(0.00);
  27. $table->decimal('total_products');
  28. $table->decimal('tax')->default(0.00);
  29. $table->decimal('total');
  30. $table->decimal('total_paid')->default(0.00);
  31. $table->string('invoice')->nullable();
  32. $table->timestamps();
  33. });
  34. }
  35. /**
  36. * Reverse the migrations.
  37. *
  38. * @return void
  39. */
  40. public function down()
  41. {
  42. Schema::dropIfExists('orders');
  43. }
  44. }