Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

...l_contentcategory_table-2016-12-04-15-32-47.php (1 issue)

1
<?php
2
3
use Ffcms\Core\Migrations\MigrationInterface;
4
use Ffcms\Core\Migrations\Migration;
5
6
/**
7
 * Class install_contentcategory_table.
8
 */
9
class install_contentcategory_table extends Migration implements MigrationInterface
0 ignored issues
show
Coding Style Compatibility introduced by zenn
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
10
{
11
    /**
12
     * Execute actions when migration is up
13
     * @return void
14
     */
15
    public function up()
16
    {
17
        $this->getSchema()->create('content_categories', function($table) {
18
            $table->increments('id');
19
            $table->string('path', 200)->unique();
20
            $table->text('title');
21
            $table->text('description')->nullable();
22
            $table->text('configs')->nullable();
23
            $table->timestamps();
24
        });
25
        parent::up();
26
    }
27
28
    /**
29
     * Seed created table via up() method with some data
30
     * @return void
31
     */
32
    public function seed()
33
    {
34
        // create categories
35
        $cat = new stdClass();
36
        $cat->General = [
37
            'title' => serialize([
38
                'ru' => 'Главная',
39
                'en' => 'General'
40
            ])
41
        ];
42
43
        $cat->News = [
44
            'title' => serialize([
45
                'ru' => 'Новости',
46
                'en' => 'News'
47
            ]),
48
            'configs' => serialize([
49
                'showDate' => '1',
50
                'showRating' => '1',
51
                'showCategory' => '1',
52
                'showAuthor' => '1',
53
                'showViews' => '1',
54
                'showComments' => '1',
55
                'showPoster' => '1',
56
                'showTags' => '1'
57
            ])
58
        ];
59
60
        $cat->Page = [
61
            'title' => serialize([
62
                'ru' => 'Страницы',
63
                'en' => 'Pages'
64
            ])
65
        ];
66
67
        $this->getConnection()->table('content_categories')->insert([
68
            ['id' => 1, 'path' => '', 'title' => $cat->General['title'], 'description' => '', 'configs' => '', 'created_at' => $this->now, 'updated_at' => $this->now],
69
            ['id' => 2, 'path' => 'news', 'title' => $cat->News['title'], 'description' => '', 'configs' => $cat->News['configs'], 'created_at' => $this->now, 'updated_at' => $this->now],
70
            ['id' => 3, 'path' => 'page', 'title' => $cat->Page['title'], 'description' => '', 'configs' => '', 'created_at' => $this->now, 'updated_at' => $this->now],
71
        ]);
72
    }
73
74
    /**
75
     * Execute actions when migration is down
76
     * @return void
77
     */
78
    public function down()
79
    {
80
        $this->getSchema()->dropIfExists('content_categories');
81
        parent::down();
82
    }
83
}