@@ -6,21 +6,21 @@ |
||
6 | 6 | { |
7 | 7 | public function up() |
8 | 8 | { |
9 | - $this->table('articles', ['id' => false, 'primary_key' => 'article_uuid']) |
|
10 | - ->addColumn('article_uuid', 'binary', ['limit' => 16]) |
|
9 | + $this->table('articles', [ 'id' => false, 'primary_key' => 'article_uuid' ]) |
|
10 | + ->addColumn('article_uuid', 'binary', [ 'limit' => 16 ]) |
|
11 | 11 | ->addColumn('article_id', 'text') |
12 | - ->addColumn('slug', 'text', ['null' => true]) |
|
13 | - ->addColumn('created_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP']) |
|
14 | - ->addColumn('published_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP']) |
|
12 | + ->addColumn('slug', 'text', [ 'null' => true ]) |
|
13 | + ->addColumn('created_at', 'datetime', [ 'default' => 'CURRENT_TIMESTAMP' ]) |
|
14 | + ->addColumn('published_at', 'datetime', [ 'default' => 'CURRENT_TIMESTAMP' ]) |
|
15 | 15 | ->addColumn('type', 'integer') // see Article\Entity\ArticleType |
16 | 16 | ->addColumn('status', 'integer') // active, not active, ... |
17 | - ->addColumn('admin_user_uuid', 'binary', ['limit' => 16]) |
|
18 | - ->addColumn('is_wysiwyg_editor', 'boolean', ['default' => false]) |
|
19 | - ->addColumn('category_uuid', 'binary', ['limit' => 16]) |
|
20 | - ->addForeignKey('category_uuid', 'category', 'category_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
21 | - ->addForeignKey('admin_user_uuid', 'admin_users', 'admin_user_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
22 | - ->addIndex('type', ['name' => 'type_INDEX']) |
|
23 | - ->addIndex('published_at', ['name' => 'published_at_INDEX']) |
|
17 | + ->addColumn('admin_user_uuid', 'binary', [ 'limit' => 16 ]) |
|
18 | + ->addColumn('is_wysiwyg_editor', 'boolean', [ 'default' => false ]) |
|
19 | + ->addColumn('category_uuid', 'binary', [ 'limit' => 16 ]) |
|
20 | + ->addForeignKey('category_uuid', 'category', 'category_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
21 | + ->addForeignKey('admin_user_uuid', 'admin_users', 'admin_user_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
22 | + ->addIndex('type', [ 'name' => 'type_INDEX' ]) |
|
23 | + ->addIndex('published_at', [ 'name' => 'published_at_INDEX' ]) |
|
24 | 24 | ->create(); |
25 | 25 | } |
26 | 26 |
@@ -9,17 +9,17 @@ |
||
9 | 9 | |
10 | 10 | public function up() |
11 | 11 | { |
12 | - $this->table('category', ['id' => false, 'primary_key' => 'category_uuid']) |
|
13 | - ->addColumn('category_uuid', 'binary', ['limit' => 16]) |
|
12 | + $this->table('category', [ 'id' => false, 'primary_key' => 'category_uuid' ]) |
|
13 | + ->addColumn('category_uuid', 'binary', [ 'limit' => 16 ]) |
|
14 | 14 | ->addColumn('category_id', 'text') |
15 | 15 | ->addColumn('name', 'text') |
16 | 16 | ->addColumn('slug', 'text') |
17 | 17 | ->addColumn('type', 'integer') // see Article\Entity\ArticleType |
18 | - ->addColumn('title', 'text', ['null' => true]) |
|
19 | - ->addColumn('description', 'text', ['null' => true]) |
|
20 | - ->addColumn('main_img', 'text', ['null' => true]) |
|
21 | - ->addColumn('is_in_homepage', 'boolean', ['default' => false]) |
|
22 | - ->addColumn('is_in_category_list', 'boolean', ['default' => true]) |
|
18 | + ->addColumn('title', 'text', [ 'null' => true ]) |
|
19 | + ->addColumn('description', 'text', [ 'null' => true ]) |
|
20 | + ->addColumn('main_img', 'text', [ 'null' => true ]) |
|
21 | + ->addColumn('is_in_homepage', 'boolean', [ 'default' => false ]) |
|
22 | + ->addColumn('is_in_category_list', 'boolean', [ 'default' => true ]) |
|
23 | 23 | ->create(); |
24 | 24 | } |
25 | 25 |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | 'select category_uuid from category where type = ' . \Article\Entity\ArticleType::EVENT), 'category_uuid' |
21 | 21 | ); |
22 | 22 | |
23 | - for($i = 0; $i < $count; $i++) { |
|
23 | + for ($i = 0; $i < $count; $i++) { |
|
24 | 24 | // Insert Article |
25 | 25 | $id = $faker->uuid; |
26 | 26 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
27 | 27 | $title = $faker->sentence(); |
28 | - $userUuid = $allUsers[rand(0, (count($allUsers) - 1))]; |
|
29 | - $categoryUuid = $allCategory[rand(0, (count($allCategory) - 1))]; |
|
28 | + $userUuid = $allUsers[ rand(0, (count($allUsers) - 1)) ]; |
|
29 | + $categoryUuid = $allCategory[ rand(0, (count($allCategory) - 1)) ]; |
|
30 | 30 | $data = [ |
31 | 31 | 'article_uuid' => $mysqlUuid, |
32 | 32 | 'article_id' => $id, |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | 'start_at' => $faker->dateTimeBetween('now', '+5 days')->format('Y-m-d H:i:s'), |
55 | 55 | 'end_at' => $faker->dateTimeBetween('+5 days', '+6 days')->format('Y-m-d H:i:s'), |
56 | 56 | 'event_url' => 'https://www.meetup.com/Tokyo-Hello-Kitty-Meetup/', |
57 | - 'featured_img' => $featuredImages[rand(0, (count($featuredImages) - 1))], |
|
58 | - 'main_img' => $mainImages[rand(0, (count($mainImages) - 1))] |
|
57 | + 'featured_img' => $featuredImages[ rand(0, (count($featuredImages) - 1)) ], |
|
58 | + 'main_img' => $mainImages[ rand(0, (count($mainImages) - 1)) ] |
|
59 | 59 | ]; |
60 | 60 | |
61 | 61 | $articleEvents->insert($data)->save(); |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | 'select category_uuid from category where type = ' . \Article\Entity\ArticleType::POST), 'category_uuid' |
21 | 21 | ); |
22 | 22 | |
23 | - for($i = 0; $i < $count; $i++) { |
|
23 | + for ($i = 0; $i < $count; $i++) { |
|
24 | 24 | // Insert Article |
25 | 25 | $id = $faker->uuid; |
26 | 26 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
27 | 27 | $title = $faker->sentence(); |
28 | - $userUuid = $allUsers[rand(0, (count($allUsers) - 1))]; |
|
29 | - $categoryUuid = $allCategory[rand(0, (count($allCategory) - 1))]; |
|
28 | + $userUuid = $allUsers[ rand(0, (count($allUsers) - 1)) ]; |
|
29 | + $categoryUuid = $allCategory[ rand(0, (count($allCategory) - 1)) ]; |
|
30 | 30 | $data = [ |
31 | 31 | 'article_uuid' => $mysqlUuid, |
32 | 32 | 'article_id' => $id, |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | 'title' => $title, |
49 | 49 | 'body' => $faker->paragraph(15), |
50 | 50 | 'lead' => $faker->paragraph(5), |
51 | - 'featured_img' => $featuredImages[rand(0, (count($featuredImages) - 1))], |
|
52 | - 'main_img' => $mainImages[rand(0, (count($mainImages) - 1))], |
|
51 | + 'featured_img' => $featuredImages[ rand(0, (count($featuredImages) - 1)) ], |
|
52 | + 'main_img' => $mainImages[ rand(0, (count($mainImages) - 1)) ], |
|
53 | 53 | 'has_layout' => true, |
54 | 54 | ]; |
55 | 55 |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | 'select category_uuid from category where type = ' . \Article\Entity\ArticleType::VIDEO), 'category_uuid' |
29 | 29 | ); |
30 | 30 | |
31 | - for($i = 0; $i < $count; $i++) { |
|
31 | + for ($i = 0; $i < $count; $i++) { |
|
32 | 32 | // Insert Article |
33 | 33 | $id = $faker->uuid; |
34 | 34 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
35 | 35 | $title = $faker->sentence(); |
36 | - $userUuid = $allUsers[rand(0, (count($allUsers) - 1))]; |
|
37 | - $categoryUuid = $allCategory[rand(0, (count($allCategory) - 1))]; |
|
36 | + $userUuid = $allUsers[ rand(0, (count($allUsers) - 1)) ]; |
|
37 | + $categoryUuid = $allCategory[ rand(0, (count($allCategory) - 1)) ]; |
|
38 | 38 | $data = [ |
39 | 39 | 'article_uuid' => $mysqlUuid, |
40 | 40 | 'article_id' => $id, |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | 'sub_title' => $faker->sentence(), |
59 | 59 | 'body' => $faker->paragraph(30), |
60 | 60 | 'lead' => $faker->paragraph(5), |
61 | - 'video_url' => self::VIDEOS[rand(0, (count(self::VIDEOS) - 1))], |
|
62 | - 'featured_img' => $featuredImages[rand(0, (count($featuredImages) - 1))], |
|
63 | - 'main_img' => $mainImages[rand(0, (count($mainImages) - 1))] |
|
61 | + 'video_url' => self::VIDEOS[ rand(0, (count(self::VIDEOS) - 1)) ], |
|
62 | + 'featured_img' => $featuredImages[ rand(0, (count($featuredImages) - 1)) ], |
|
63 | + 'main_img' => $mainImages[ rand(0, (count($mainImages) - 1)) ] |
|
64 | 64 | ]; |
65 | 65 | |
66 | 66 | $articleVideos->insert($data)->save(); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | namespace Web\Factory\Action; |
5 | 5 | |
6 | 6 | use Article\Service\PostService; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | namespace Meetup; |
4 | 4 | |
5 | 5 | use GuzzleHttp\Client; |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | public function getAttendees($eventUrl) |
35 | 35 | { |
36 | 36 | if (strpos($eventUrl, 'meetup.com') === false) { |
37 | - return []; |
|
37 | + return [ ]; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | try { |
41 | 41 | $parts = explode('/', $eventUrl); |
42 | - $meetupId = $parts[count($parts) - 2]; |
|
42 | + $meetupId = $parts[ count($parts) - 2 ]; |
|
43 | 43 | $uri = sprintf(self::API_URL, $meetupId, $this->key); |
44 | 44 | $request = new Request('GET', $uri); |
45 | 45 | $response = $this->httpClient->send($request); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | return $attendees; |
51 | 51 | } catch (\Exception $e) { |
52 | - return []; |
|
52 | + return [ ]; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
@@ -36,18 +36,18 @@ discard block |
||
36 | 36 | public function getPaginationSelect($status = null) |
37 | 37 | { |
38 | 38 | $select = $this->getSql()->select() |
39 | - ->columns(['title', 'body', 'longitude', 'latitude']) |
|
39 | + ->columns([ 'title', 'body', 'longitude', 'latitude' ]) |
|
40 | 40 | ->join('articles', |
41 | 41 | 'article_events.article_uuid = articles.article_uuid') |
42 | 42 | ->join( |
43 | 43 | 'admin_users', |
44 | 44 | 'admin_users.admin_user_uuid = articles.admin_user_uuid', |
45 | - ['admin_user_id', 'first_name', 'last_name'] |
|
46 | - )->where(['articles.type' => ArticleType::EVENT]) |
|
47 | - ->order(['created_at' => 'desc']); |
|
45 | + [ 'admin_user_id', 'first_name', 'last_name' ] |
|
46 | + )->where([ 'articles.type' => ArticleType::EVENT ]) |
|
47 | + ->order([ 'created_at' => 'desc' ]); |
|
48 | 48 | |
49 | 49 | if ($status) { |
50 | - $select->where(['articles.status' => (int)$status]); |
|
50 | + $select->where([ 'articles.status' => (int) $status ]); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | return $select; |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | ) |
69 | 69 | ->join('admin_users', |
70 | 70 | 'admin_users.admin_user_uuid = articles.admin_user_uuid', |
71 | - ['admin_user_id'], 'left') |
|
72 | - ->where(['articles.article_id' => $id]); |
|
71 | + [ 'admin_user_id' ], 'left') |
|
72 | + ->where([ 'articles.article_id' => $id ]); |
|
73 | 73 | |
74 | 74 | return $this->selectWith($select)->current(); |
75 | 75 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | 'category_id' |
88 | 88 | ], 'left' |
89 | 89 | ) |
90 | - ->where(['articles.slug' => $slug]); |
|
90 | + ->where([ 'articles.slug' => $slug ]); |
|
91 | 91 | |
92 | 92 | return $this->selectWith($select)->current(); |
93 | 93 | } |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | $select = $this->getSql()->select() |
98 | 98 | ->join('articles', |
99 | 99 | 'article_events.article_uuid = articles.article_uuid', |
100 | - ['article_id', 'slug', 'published_at']) |
|
100 | + [ 'article_id', 'slug', 'published_at' ]) |
|
101 | 101 | ->join('category', |
102 | 102 | 'category.category_uuid = articles.category_uuid', |
103 | - ['category_slug' => 'slug']) |
|
104 | - ->where(['articles.status' => 1]) |
|
105 | - ->order(['published_at' => 'desc']) |
|
103 | + [ 'category_slug' => 'slug' ]) |
|
104 | + ->where([ 'articles.status' => 1 ]) |
|
105 | + ->order([ 'published_at' => 'desc' ]) |
|
106 | 106 | ->limit($limit); |
107 | 107 | |
108 | 108 | return $this->selectWith($select); |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | public function getFuture() |
112 | 112 | { |
113 | 113 | $select = $this->getSql()->select() |
114 | - ->where(['articles.status' => 1]) |
|
114 | + ->where([ 'articles.status' => 1 ]) |
|
115 | 115 | ->join('articles', |
116 | 116 | 'articles.article_uuid = article_events.article_uuid', |
117 | - ['article_id', 'slug', 'published_at']) |
|
117 | + [ 'article_id', 'slug', 'published_at' ]) |
|
118 | 118 | ->join('category', |
119 | 119 | 'category.category_uuid = articles.category_uuid', |
120 | - ['category_slug' => 'slug']) |
|
120 | + [ 'category_slug' => 'slug' ]) |
|
121 | 121 | ->order(new Expression('rand()')); |
122 | 122 | |
123 | 123 | $select->where->greaterThanOrEqualTo('end_at', date('Y-m-d H:i:s')); |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | public function getPastSelect() |
129 | 129 | { |
130 | 130 | $select = $this->getSql()->select() |
131 | - ->where(['articles.status' => 1]) |
|
131 | + ->where([ 'articles.status' => 1 ]) |
|
132 | 132 | ->join('articles', |
133 | 133 | 'articles.article_uuid = article_events.article_uuid', |
134 | - ['article_id', 'slug', 'published_at']) |
|
134 | + [ 'article_id', 'slug', 'published_at' ]) |
|
135 | 135 | ->join('category', |
136 | 136 | 'category.category_uuid = articles.category_uuid', |
137 | - ['category_slug' => 'slug']) |
|
138 | - ->order(['start_at' => 'desc']); |
|
137 | + [ 'category_slug' => 'slug' ]) |
|
138 | + ->order([ 'start_at' => 'desc' ]); |
|
139 | 139 | $select->where->lessThan('end_at', date('Y-m-d H:i:s')); |
140 | 140 | |
141 | 141 | return $select; |
@@ -34,16 +34,16 @@ discard block |
||
34 | 34 | { |
35 | 35 | $select = $this->getSql()->select() |
36 | 36 | ->join('articles', 'article_videos.article_uuid = articles.article_uuid', |
37 | - ['slug', 'published_at', 'status', 'article_id']) |
|
37 | + [ 'slug', 'published_at', 'status', 'article_id' ]) |
|
38 | 38 | ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', |
39 | - ['admin_user_id', 'first_name', 'last_name']) |
|
39 | + [ 'admin_user_id', 'first_name', 'last_name' ]) |
|
40 | 40 | ->join('category', 'category.category_uuid = articles.category_uuid', |
41 | - ['category_slug' => 'slug']) |
|
42 | - ->where(['articles.type' => ArticleType::VIDEO]) |
|
43 | - ->order(['articles.created_at' => 'desc']); |
|
41 | + [ 'category_slug' => 'slug' ]) |
|
42 | + ->where([ 'articles.type' => ArticleType::VIDEO ]) |
|
43 | + ->order([ 'articles.created_at' => 'desc' ]); |
|
44 | 44 | |
45 | 45 | if ($isActive !== null) { |
46 | - $select->where(['articles.status' => (int)$isActive]); |
|
46 | + $select->where([ 'articles.status' => (int) $isActive ]); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | return $select; |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | public function get($id) |
53 | 53 | { |
54 | 54 | $select = $this->getSql()->select() |
55 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'video_url', 'sub_title']) |
|
55 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'video_url', 'sub_title' ]) |
|
56 | 56 | ->join('articles', 'article_videos.article_uuid = articles.article_uuid') |
57 | 57 | ->join( |
58 | 58 | 'category', 'category.category_uuid = articles.category_uuid', |
59 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left' |
|
59 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left' |
|
60 | 60 | ) |
61 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id'], 'left') |
|
62 | - ->where(['articles.article_id' => $id]); |
|
61 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id' ], 'left') |
|
62 | + ->where([ 'articles.article_id' => $id ]); |
|
63 | 63 | |
64 | 64 | return $this->selectWith($select)->current(); |
65 | 65 | } |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | public function getLatest($limit = 50) |
68 | 68 | { |
69 | 69 | $select = $this->getSql()->select() |
70 | - ->join('articles', 'article_videos.article_uuid = articles.article_uuid', ['article_id', 'slug', 'published_at']) |
|
71 | - ->join('category', 'category.category_uuid = articles.category_uuid', ['category_slug' => 'slug']) |
|
72 | - ->where(['articles.status' => 1]) |
|
73 | - ->order(['published_at' => 'desc']) |
|
70 | + ->join('articles', 'article_videos.article_uuid = articles.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
71 | + ->join('category', 'category.category_uuid = articles.category_uuid', [ 'category_slug' => 'slug' ]) |
|
72 | + ->where([ 'articles.status' => 1 ]) |
|
73 | + ->order([ 'published_at' => 'desc' ]) |
|
74 | 74 | ->limit($limit); |
75 | 75 | |
76 | 76 | return $this->selectWith($select); |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | { |
81 | 81 | $select = $this->getSql()->select() |
82 | 82 | ->join('articles', 'article_videos.article_uuid = articles.article_uuid') |
83 | - ->join('category', 'category.category_uuid = articles.category_uuid', ['category_slug' => 'slug']) |
|
84 | - ->where(['articles.slug' => $slug]); |
|
83 | + ->join('category', 'category.category_uuid = articles.category_uuid', [ 'category_slug' => 'slug' ]) |
|
84 | + ->where([ 'articles.slug' => $slug ]); |
|
85 | 85 | |
86 | 86 | return $this->selectWith($select)->current(); |
87 | 87 | } |