CreateOrdersTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 29
rs 9.584
cc 1
nc 1
nop 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreateOrdersTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('orders', function (Blueprint $table) {
17
            $table->id();
18
            $table->unsignedBigInteger('user_id');
19
            $table->date('shipped_date')->nullable();
20
            $table->decimal('total_price');
21
            $table->decimal('shipping_price')->default(0);
22
            $table->text('id_shipping')->nullable();
23
            $table->text('note_delivery')->nullable();
24
            $table->boolean('pick_up_in_shop')->default(false);
25
            $table->decimal('order_weight')->default(0);
26
27
28
            $table->unsignedBigInteger('status_id');
29
            $table->unsignedBigInteger('payment_type_id');
30
31
            $table->string('telephone')->nullable();
32
            $table->string('address')->nullable();
33
            $table->string('province')->nullable();
34
            $table->string('city')->nullable();
35
            $table->string('cap')->nullable();
36
37
            $table->timestamps();
38
39
            //fk
40
            $table->foreign('user_id')->references('id')->on('users');
41
            $table->foreign('status_id')->references('id')->on('statuses_order');
42
            $table->foreign('payment_type_id')->references('id')->on('payment_type');
43
        });
44
    }
45
46
    /**
47
     * Reverse the migrations.
48
     *
49
     * @return void
50
     */
51
    public function down()
52
    {
53
        Schema::dropIfExists('orders');
54
    }
55
}
56