1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Database\Schema\Blueprint; |
4
|
|
|
use Illuminate\Database\Migrations\Migration; |
5
|
|
|
|
6
|
|
|
class NewsTable extends Migration |
7
|
|
|
{ |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Run the migrations. |
11
|
|
|
* |
12
|
|
|
* @return void |
13
|
|
|
*/ |
14
|
|
|
public function up() |
15
|
|
|
{ |
16
|
|
|
Schema::create('news', function (Blueprint $table) { |
17
|
|
|
$table->increments('id'); |
18
|
|
|
$table->string('title')->nullable(); |
19
|
|
|
$table->text('short_description')->nullable(); |
20
|
|
|
$table->text('content')->nullable(); |
21
|
|
|
$table->string('meta_title')->nullable(); |
22
|
|
|
$table->string('meta_description')->nullable(); |
23
|
|
|
$table->string('meta_keywords')->nullable(); |
24
|
|
|
$table->string('slug'); |
25
|
|
|
$table->date('published_at')->nullable(); |
26
|
|
|
$table->integer('shop_id')->unsigned()->nullable(); |
27
|
|
|
$table->foreign('shop_id')->references('id')->on('shop')->onDelete('cascade'); |
28
|
|
|
$table->integer('modified_by_user_id')->unsigned()->nullable(); |
29
|
|
|
$table->foreign('modified_by_user_id')->references('id')->on('user')->onDelete('set null'); |
30
|
|
|
$table->timestamps(); |
31
|
|
|
$table->unique(array('title','shop_id'), 'unique_news_title'); |
32
|
|
|
}); |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
Schema::create('news_image', function (Blueprint $table) { |
36
|
|
|
$table->increments('id'); |
37
|
|
|
$table->integer('news_id')->unsigned(); |
38
|
|
|
$table->foreign('news_id')->references('id')->on('news')->onDelete('cascade'); |
39
|
|
|
$table->string('file')->nullable(); |
40
|
|
|
$table->string('path')->nullable(); |
41
|
|
|
$table->integer('size')->nullable(); |
42
|
|
|
$table->string('extension')->nullable(); |
43
|
|
|
$table->integer('rank')->default(0); |
44
|
|
|
$table->string('tag')->nullable(); |
45
|
|
|
$table->integer('modified_by_user_id')->unsigned()->nullable(); |
46
|
|
|
$table->foreign('modified_by_user_id')->references('id')->on('user')->onDelete('set null'); |
47
|
|
|
$table->timestamps(); |
48
|
|
|
}); |
49
|
|
|
|
50
|
|
|
// Creates the users table |
51
|
|
|
Schema::create('news_group', function ($table) { |
52
|
|
|
$table->increments('id'); |
53
|
|
|
$table->boolean('active')->default(false); |
54
|
|
|
$table->integer('rank')->default(0); |
55
|
|
|
$table->string('title'); |
56
|
|
|
$table->string('meta_title')->nullable(); |
57
|
|
|
$table->string('meta_description')->nullable(); |
58
|
|
|
$table->string('meta_keywords')->nullable(); |
59
|
|
|
$table->string('slug'); |
60
|
|
|
$table->integer('shop_id')->unsigned(); |
61
|
|
|
$table->foreign('shop_id')->references('id')->on('shop')->onDelete('cascade'); |
62
|
|
|
$table->integer('modified_by_user_id')->unsigned()->nullable(); |
63
|
|
|
$table->foreign('modified_by_user_id')->references('id')->on('user')->onDelete('set null'); |
64
|
|
|
$table->unique(array('title','shop_id'), 'unique_news_group_title'); |
65
|
|
|
$table->timestamps(); |
66
|
|
|
}); |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
Schema::table('news', function (Blueprint $table) { |
70
|
|
|
$table->integer('news_group_id')->unsigned()->nullable(); |
71
|
|
|
$table->foreign('news_group_id')->references('id')->on('news_group')->onDelete('set null'); |
72
|
|
|
}); |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Reverse the migrations. |
78
|
|
|
* |
79
|
|
|
* @return void |
80
|
|
|
*/ |
81
|
|
|
public function down() |
82
|
|
|
{ |
83
|
|
|
// |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|