Completed
Push — master ( eebd52...3cd9a5 )
by ARCANEDEV
08:34
created

CreateBlogPostsTable::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
use Arcanesoft\Blog\Bases\Migration;
4
use Arcanesoft\Blog\Entities\PostStatus;
5
use Illuminate\Database\Schema\Blueprint;
6
7
/**
8
 * Class     CreateBlogPostsTable
9
 *
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class CreateBlogPostsTable extends Migration
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Constructor
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * CreateBlogPostsTable constructor.
20
     */
21
    public function __construct()
22
    {
23
        parent::__construct();
24
25
        $this->setTable('posts');
26
    }
27
28
    /* ------------------------------------------------------------------------------------------------
29
     |  Main Functions
30
     | ------------------------------------------------------------------------------------------------
31
     */
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function up()
36
    {
37
        $this->createSchema(function(Blueprint $table) {
38
            $table->increments('id');
39
40
            $table->integer('user_id')->unsigned()->default(0);
41
            $table->integer('category_id')->unsigned();
42
43
            $table->string('title');
44
            $table->string('slug');
45
            $table->text('excerpt');
46
            $table->longtext('content');
47
            $table->enum('status', PostStatus::keys());
48
49
            $table->dateTime('publish_date');
50
            $table->timestamps();
51
            $table->softDeletes();
52
53
            $table->unique('slug');
54
        });
55
    }
56
}
57