1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Database\Migrations\Migration; |
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
5
|
|
|
use Illuminate\Support\Facades\Schema; |
6
|
|
|
|
7
|
|
|
class CreateMigrationsTable extends Migration |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Run the migrations. |
11
|
|
|
* |
12
|
|
|
* @return void |
13
|
|
|
*/ |
14
|
|
|
public function up() |
15
|
|
|
{ |
16
|
|
|
Schema::create('inventories', function (Blueprint $table) { |
17
|
|
|
$table->increments('id'); |
18
|
|
|
$table->integer('public_id'); |
19
|
|
|
$table->string('name', 80); |
20
|
|
|
$table->string('description', 120); |
21
|
|
|
$table->integer('material_type_id')->unsigned(); |
22
|
|
|
$table->integer('brand_id')->unsigned(); |
23
|
|
|
$table->integer('model_id')->unsigned(); |
24
|
|
|
$table->integer('location_id')->unsigned(); |
25
|
|
|
$table->integer('quantity'); |
26
|
|
|
$table->double('price'); |
27
|
|
|
$table->integer('moneysourceId')->unsigned(); |
28
|
|
|
$table->integer('provider_id')->unsigned(); |
29
|
|
|
$table->date('date_entrance'); |
30
|
|
|
$table->date('last_update'); |
31
|
|
|
$table->string('picture', 60); |
32
|
|
|
$table->timestamps(); |
33
|
|
|
$table->softDeletes(); |
34
|
|
|
}); |
35
|
|
|
|
36
|
|
|
Schema::table('inventories', function ($table) { |
37
|
|
|
$table->foreign('material_type_id')->references('id')->on('material_type')->onDelete('cascade'); |
38
|
|
|
$table->foreign('brand_id')->references('id')->on('brand')->onDelete('cascade'); |
39
|
|
|
$table->foreign('model_id')->references('id')->on('brand_model')->onDelete('cascade'); |
40
|
|
|
$table->foreign('location_id')->references('id')->on('location')->onDelete('cascade'); |
41
|
|
|
$table->foreign('moneySourceId')->references('id')->on('moneySource')->onDelete('cascade'); |
42
|
|
|
$table->foreign('provider_id')->references('id')->on('providers')->onDelete('cascade'); |
43
|
|
|
}); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Reverse the migrations. |
48
|
|
|
* |
49
|
|
|
* @return void |
50
|
|
|
*/ |
51
|
|
|
public function down() |
52
|
|
|
{ |
53
|
|
|
Schema::dropIfExists('inventories'); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.