1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Database\Migrations\Migration; |
4
|
|
|
use \jlourenco\support\Database\Blueprint; |
5
|
|
|
|
6
|
|
|
class CreateBlogTables extends Migration |
|
|
|
|
7
|
|
|
{ |
8
|
|
|
/** |
9
|
|
|
* Run the migrations. |
10
|
|
|
* |
11
|
|
|
* @return void |
12
|
|
|
*/ |
13
|
|
|
public function up() |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
Schema::create('BlogCategory', function (Blueprint $table) { |
17
|
|
|
$table->increments('id'); |
18
|
|
|
$table->string('name', 100); |
19
|
|
|
$table->string('slug', 100); |
20
|
|
|
$table->string('description', 250); |
21
|
|
|
|
22
|
|
|
$table->timestamps(); |
23
|
|
|
$table->softDeletes(); |
24
|
|
|
$table->creation(); |
25
|
|
|
}); |
26
|
|
|
|
27
|
|
|
Schema::table('BlogCategory', function (Blueprint $table) { |
28
|
|
|
$table->creationRelation(); |
29
|
|
|
}); |
30
|
|
|
|
31
|
|
|
Schema::create('BlogPost', function (Blueprint $table) { |
32
|
|
|
$table->increments('id'); |
33
|
|
|
$table->string('title', 100); |
34
|
|
|
$table->string('slug', 100); |
35
|
|
|
$table->text('contents'); |
36
|
|
|
$table->integer('category')->unsigned(); |
37
|
|
|
$table->integer('author')->unsigned(); |
38
|
|
|
$table->integer('likes')->default(0); |
39
|
|
|
$table->integer('shares')->default(0); |
40
|
|
|
$table->integer('views')->default(0); |
41
|
|
|
$table->string('keywords', 250); |
42
|
|
|
|
43
|
|
|
$table->timestamps(); |
44
|
|
|
$table->softDeletes(); |
45
|
|
|
$table->creation(); |
46
|
|
|
|
47
|
|
|
$table->foreign('category')->references('id')->on('BlogCategory'); |
48
|
|
|
$table->foreign('author')->references('id')->on('User'); |
49
|
|
|
}); |
50
|
|
|
|
51
|
|
|
Schema::table('BlogPost', function (Blueprint $table) { |
52
|
|
|
$table->creationRelation(); |
53
|
|
|
}); |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Reverse the migrations. |
59
|
|
|
* |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
|
|
public function down() |
63
|
|
|
{ |
64
|
|
|
|
65
|
|
|
Schema::drop('BlogPost'); |
66
|
|
|
Schema::drop('BlogCategory'); |
67
|
|
|
|
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
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.