CreateBlogPostsTable::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
use Arcanesoft\Blog\Bases\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
6
/**
7
 * Class     CreateBlogPostsTable
8
 *
9
 * @author   ARCANEDEV <[email protected]>
10
 *
11
 * @see \Arcanesoft\Blog\Models\Post
12
 */
13
class CreateBlogPostsTable extends Migration
14
{
15
    /* -----------------------------------------------------------------
16
     |  Constructor
17
     | -----------------------------------------------------------------
18
     */
19
20
    /**
21
     * CreateBlogPostsTable constructor.
22
     */
23
    public function __construct()
24
    {
25
        parent::__construct();
26
27
        $this->setTable('posts');
28
    }
29
30
    /* -----------------------------------------------------------------
31
     |  Main Methods
32
     | -----------------------------------------------------------------
33
     */
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function up()
39
    {
40
        $this->createSchema(function(Blueprint $table) {
41
            $table->increments('id');
42
            $table->unsignedInteger('author_id')->default(0);
43
            $table->unsignedInteger('category_id');
44
            $table->string('locale', 5)->default(config('app.locale'));
45
            $table->string('title');
46
            $table->string('slug');
47
            $table->text('excerpt');
48
            $table->string('thumbnail')->nullable();
49
            $table->longtext('content_raw');
50
            $table->longtext('content_html');
51
            $table->boolean('is_draft')->default(false);
52
            $table->timestamps();
53
            $table->timestamp('published_at')->nullable();
54
            $table->softDeletes();
55
56
            $table->unique(['locale', 'slug']);
57
        });
58
    }
59
}
60