@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Article\Service; |
6 | 6 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
91 | 91 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
92 | 92 | |
93 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
93 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
94 | 94 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
95 | 95 | } |
96 | 96 | |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | 'article_uuid' => $uuId |
105 | 105 | ]; |
106 | 106 | |
107 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
108 | - unset($article['category_id']); |
|
107 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
108 | + unset($article[ 'category_id' ]); |
|
109 | 109 | |
110 | 110 | $post = $postFilter->getValues() + [ |
111 | 111 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
112 | 112 | 'main_img' => $this->upload->uploadImage($data, 'main_img'), |
113 | - 'article_uuid' => $article['article_uuid'] |
|
113 | + 'article_uuid' => $article[ 'article_uuid' ] |
|
114 | 114 | ]; |
115 | 115 | |
116 | - if($post['is_homepage']) { |
|
117 | - $this->articlePostsMapper->update(['is_homepage' => false]); |
|
116 | + if ($post[ 'is_homepage' ]) { |
|
117 | + $this->articlePostsMapper->update([ 'is_homepage' => false ]); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | $this->articleMapper->insert($article); |
@@ -127,45 +127,45 @@ discard block |
||
127 | 127 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
128 | 128 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
129 | 129 | |
130 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
130 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
131 | 131 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
132 | 132 | } |
133 | 133 | |
134 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
134 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
135 | 135 | $post = $postFilter->getValues() + [ |
136 | 136 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
137 | 137 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
138 | 138 | ]; |
139 | 139 | |
140 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
141 | - unset($article['category_id']); |
|
140 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
141 | + unset($article[ 'category_id' ]); |
|
142 | 142 | |
143 | 143 | // We dont want to force user to re-upload image on edit |
144 | - if(!$post['featured_img']) { |
|
145 | - unset($post['featured_img']); |
|
144 | + if (!$post[ 'featured_img' ]) { |
|
145 | + unset($post[ 'featured_img' ]); |
|
146 | 146 | } |
147 | 147 | |
148 | - if(!$post['main_img']) { |
|
149 | - unset($post['main_img']); |
|
148 | + if (!$post[ 'main_img' ]) { |
|
149 | + unset($post[ 'main_img' ]); |
|
150 | 150 | } |
151 | 151 | |
152 | - if($post['is_homepage']) { |
|
153 | - $this->articlePostsMapper->update(['is_homepage' => false]); |
|
152 | + if ($post[ 'is_homepage' ]) { |
|
153 | + $this->articlePostsMapper->update([ 'is_homepage' => false ]); |
|
154 | 154 | } |
155 | 155 | |
156 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
157 | - $this->articlePostsMapper->update($post, ['article_uuid' => $article['article_uuid']]); |
|
156 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
157 | + $this->articlePostsMapper->update($post, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function deleteArticle($id) |
161 | 161 | { |
162 | 162 | $post = $this->articlePostsMapper->get($id); |
163 | 163 | |
164 | - if(!$post) { |
|
164 | + if (!$post) { |
|
165 | 165 | throw new \Exception('Article not found!'); |
166 | 166 | } |
167 | 167 | |
168 | - $this->articlePostsMapper->delete(['article_uuid' => $post->article_uuid]); |
|
168 | + $this->articlePostsMapper->delete([ 'article_uuid' => $post->article_uuid ]); |
|
169 | 169 | $this->delete($post->article_uuid); |
170 | 170 | } |
171 | 171 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
51 | 51 | $discussionFilter = $this->discussionFilter->getInputFilter()->setData($data); |
52 | 52 | |
53 | - if(!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
53 | + if (!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
54 | 54 | throw new FilterException($articleFilter->getMessages() + $discussionFilter->getMessages()); |
55 | 55 | } |
56 | 56 | |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | 'article_uuid' => $uuId |
65 | 65 | ]; |
66 | 66 | |
67 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
68 | - unset($article['category_id']); |
|
67 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
68 | + unset($article[ 'category_id' ]); |
|
69 | 69 | |
70 | - $discussion = $discussionFilter->getValues() + ['article_uuid' => $uuId]; |
|
70 | + $discussion = $discussionFilter->getValues() + [ 'article_uuid' => $uuId ]; |
|
71 | 71 | |
72 | 72 | $this->articleMapper->insert($article); |
73 | 73 | $this->articleDiscussionsMapper->insert($discussion); |
@@ -79,29 +79,29 @@ discard block |
||
79 | 79 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
80 | 80 | $discussionFilter = $this->discussionFilter->getInputFilter()->setData($data); |
81 | 81 | |
82 | - if(!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
82 | + if (!$articleFilter->isValid() || !$discussionFilter->isValid()) { |
|
83 | 83 | throw new FilterException($articleFilter->getMessages() + $discussionFilter->getMessages()); |
84 | 84 | } |
85 | 85 | |
86 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
86 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
87 | 87 | $discussion = $discussionFilter->getValues(); |
88 | 88 | |
89 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
90 | - unset($article['category_id']); |
|
89 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
90 | + unset($article[ 'category_id' ]); |
|
91 | 91 | |
92 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
93 | - $this->articleDiscussionsMapper->update($discussion, ['article_uuid' => $article['article_uuid']]); |
|
92 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
93 | + $this->articleDiscussionsMapper->update($discussion, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public function deleteArticle($id) |
97 | 97 | { |
98 | 98 | $discussion = $this->articleDiscussionsMapper->get($id); |
99 | 99 | |
100 | - if(!$discussion) { |
|
100 | + if (!$discussion) { |
|
101 | 101 | throw new \Exception('Article not found!'); |
102 | 102 | } |
103 | 103 | |
104 | - $this->articleDiscussionsMapper->delete(['article_uuid' => $discussion->article_uuid]); |
|
104 | + $this->articleDiscussionsMapper->delete([ 'article_uuid' => $discussion->article_uuid ]); |
|
105 | 105 | $this->delete($discussion->article_uuid); |
106 | 106 | } |
107 | 107 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
84 | 84 | $eventFilter = $this->eventFilter->getInputFilter()->setData($data); |
85 | 85 | |
86 | - if(!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
86 | + if (!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
87 | 87 | throw new FilterException($articleFilter->getMessages() + $eventFilter->getMessages()); |
88 | 88 | } |
89 | 89 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | 'article_uuid' => $uuId |
98 | 98 | ]; |
99 | 99 | |
100 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
101 | - unset($article['category_id']); |
|
100 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
101 | + unset($article[ 'category_id' ]); |
|
102 | 102 | |
103 | 103 | $event = $eventFilter->getValues() + [ |
104 | 104 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -116,41 +116,41 @@ discard block |
||
116 | 116 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
117 | 117 | $eventFilter = $this->eventFilter->getInputFilter()->setData($data); |
118 | 118 | |
119 | - if(!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
119 | + if (!$articleFilter->isValid() || !$eventFilter->isValid()) { |
|
120 | 120 | throw new FilterException($articleFilter->getMessages() + $eventFilter->getMessages()); |
121 | 121 | } |
122 | 122 | |
123 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
123 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
124 | 124 | $event = $eventFilter->getValues() + [ |
125 | 125 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
126 | 126 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
127 | 127 | ]; |
128 | 128 | |
129 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
130 | - unset($article['category_id']); |
|
129 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
130 | + unset($article[ 'category_id' ]); |
|
131 | 131 | |
132 | 132 | // We dont want to force user to re-upload image on edit |
133 | - if(!$event['featured_img']) { |
|
134 | - unset($event['featured_img']); |
|
133 | + if (!$event[ 'featured_img' ]) { |
|
134 | + unset($event[ 'featured_img' ]); |
|
135 | 135 | } |
136 | 136 | |
137 | - if(!$event['main_img']) { |
|
138 | - unset($event['main_img']); |
|
137 | + if (!$event[ 'main_img' ]) { |
|
138 | + unset($event[ 'main_img' ]); |
|
139 | 139 | } |
140 | 140 | |
141 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
142 | - $this->articleEventsMapper->update($event, ['article_uuid' => $article['article_uuid']]); |
|
141 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
142 | + $this->articleEventsMapper->update($event, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | public function deleteArticle($id) |
146 | 146 | { |
147 | 147 | $event = $this->articleEventsMapper->get($id); |
148 | 148 | |
149 | - if(!$event) { |
|
149 | + if (!$event) { |
|
150 | 150 | throw new \Exception('Article not found!'); |
151 | 151 | } |
152 | 152 | |
153 | - $this->articleEventsMapper->delete(['article_uuid' => $event->article_uuid]); |
|
153 | + $this->articleEventsMapper->delete([ 'article_uuid' => $event->article_uuid ]); |
|
154 | 154 | $this->delete($event->article_uuid); |
155 | 155 | } |
156 | 156 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Article\Mapper; |
6 | 6 | |
@@ -21,20 +21,20 @@ discard block |
||
21 | 21 | public function getPaginationSelect() |
22 | 22 | { |
23 | 23 | return $this->getSql()->select() |
24 | - ->columns(['title', 'body']) |
|
24 | + ->columns([ 'title', 'body' ]) |
|
25 | 25 | ->join('articles', 'article_discussions.article_uuid = articles.article_uuid') |
26 | - ->where(['articles.type' => ArticleType::DISCUSSION]) |
|
27 | - ->order(['created_at' => 'desc']); |
|
26 | + ->where([ 'articles.type' => ArticleType::DISCUSSION ]) |
|
27 | + ->order([ 'created_at' => 'desc' ]); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function get($id) |
31 | 31 | { |
32 | 32 | $select = $this->getSql()->select() |
33 | - ->columns(['title', 'body']) |
|
33 | + ->columns([ 'title', 'body' ]) |
|
34 | 34 | ->join('articles', 'article_discussions.article_uuid = articles.article_uuid') |
35 | 35 | ->join('category', 'category.category_uuid = articles.category_uuid', |
36 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left') |
|
37 | - ->where(['articles.article_id' => $id]); |
|
36 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left') |
|
37 | + ->where([ 'articles.article_id' => $id ]); |
|
38 | 38 | |
39 | 39 | return $this->selectWith($select)->current(); |
40 | 40 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Article\Mapper; |
6 | 6 | |
@@ -36,14 +36,14 @@ 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', 'article_events.article_uuid = articles.article_uuid') |
41 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id', 'first_name', 'last_name']) |
|
42 | - ->where(['articles.type' => ArticleType::EVENT]) |
|
43 | - ->order(['created_at' => 'desc']); |
|
41 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id', 'first_name', 'last_name' ]) |
|
42 | + ->where([ 'articles.type' => ArticleType::EVENT ]) |
|
43 | + ->order([ 'created_at' => 'desc' ]); |
|
44 | 44 | |
45 | - if($status) { |
|
46 | - $select->where(['articles.status' => (int)$status]); |
|
45 | + if ($status) { |
|
46 | + $select->where([ 'articles.status' => (int) $status ]); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | return $select; |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | $select = $this->getSql()->select() |
55 | 55 | ->join('articles', 'article_events.article_uuid = articles.article_uuid') |
56 | 56 | ->join('category', 'category.category_uuid = articles.category_uuid', |
57 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left') |
|
58 | - ->where(['articles.article_id' => $id]); |
|
57 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left') |
|
58 | + ->where([ 'articles.article_id' => $id ]); |
|
59 | 59 | |
60 | 60 | return $this->selectWith($select)->current(); |
61 | 61 | } |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | { |
65 | 65 | $select = $this->getSql()->select() |
66 | 66 | ->join('articles', 'article_events.article_uuid = articles.article_uuid') |
67 | - ->join('category', 'category.category_uuid = articles.category_uuid', ['*'], 'left') |
|
68 | - ->where(['articles.slug' => $slug]); |
|
67 | + ->join('category', 'category.category_uuid = articles.category_uuid', [ '*' ], 'left') |
|
68 | + ->where([ 'articles.slug' => $slug ]); |
|
69 | 69 | |
70 | 70 | return $this->selectWith($select)->current(); |
71 | 71 | } |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | public function getLatest($limit = 50) |
74 | 74 | { |
75 | 75 | $select = $this->getSql()->select() |
76 | - ->join('articles', 'article_events.article_uuid = articles.article_uuid', ['article_id', 'slug', 'published_at']) |
|
77 | - ->where(['articles.status' => 1]) |
|
78 | - ->order(['published_at' => 'desc']) |
|
76 | + ->join('articles', 'article_events.article_uuid = articles.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
77 | + ->where([ 'articles.status' => 1 ]) |
|
78 | + ->order([ 'published_at' => 'desc' ]) |
|
79 | 79 | ->limit($limit); |
80 | 80 | |
81 | 81 | return $this->selectWith($select); |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | public function getFuture() |
85 | 85 | { |
86 | 86 | $select = $this->getSql()->select() |
87 | - ->where(['articles.status' => 1]) |
|
88 | - ->join('articles', 'articles.article_uuid = article_events.article_uuid', ['article_id', 'slug', 'published_at']) |
|
87 | + ->where([ 'articles.status' => 1 ]) |
|
88 | + ->join('articles', 'articles.article_uuid = article_events.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
89 | 89 | ->order(new Expression('rand()')); |
90 | 90 | |
91 | 91 | $select->where->greaterThanOrEqualTo('end_at', date('Y-m-d H:i:s')); |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | public function getPastSelect() |
97 | 97 | { |
98 | 98 | $select = $this->getSql()->select() |
99 | - ->where(['articles.status' => 1]) |
|
100 | - ->join('articles', 'articles.article_uuid = article_events.article_uuid', ['article_id', 'slug', 'published_at']) |
|
101 | - ->order(['start_at' => 'desc']); |
|
99 | + ->where([ 'articles.status' => 1 ]) |
|
100 | + ->join('articles', 'articles.article_uuid = article_events.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
101 | + ->order([ 'start_at' => 'desc' ]); |
|
102 | 102 | |
103 | 103 | $select->where->lessThan('end_at', date('Y-m-d H:i:s')); |
104 | 104 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Article\Mapper; |
5 | 5 | |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | public function getPaginationSelect($isActive = null) |
35 | 35 | { |
36 | 36 | $select = $this->getSql()->select() |
37 | - ->join('articles', 'article_videos.article_uuid = articles.article_uuid', ['slug', 'published_at', 'status', 'article_id']) |
|
38 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id', 'first_name', 'last_name']) |
|
39 | - ->where(['articles.type' => ArticleType::POST]) |
|
40 | - ->order(['articles.created_at' => 'desc']); |
|
37 | + ->join('articles', 'article_videos.article_uuid = articles.article_uuid', [ 'slug', 'published_at', 'status', 'article_id' ]) |
|
38 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id', 'first_name', 'last_name' ]) |
|
39 | + ->where([ 'articles.type' => ArticleType::POST ]) |
|
40 | + ->order([ 'articles.created_at' => 'desc' ]); |
|
41 | 41 | |
42 | - if($isActive !== null) { |
|
43 | - $select->where(['articles.status' => (int)$isActive]); |
|
42 | + if ($isActive !== null) { |
|
43 | + $select->where([ 'articles.status' => (int) $isActive ]); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return $select; |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | public function get($id) |
50 | 50 | { |
51 | 51 | $select = $this->getSql()->select() |
52 | - ->columns(['title', 'body', 'lead', 'featured_img', 'main_img', 'video_url', 'sub_title']) |
|
52 | + ->columns([ 'title', 'body', 'lead', 'featured_img', 'main_img', 'video_url', 'sub_title' ]) |
|
53 | 53 | ->join('articles', 'article_videos.article_uuid = articles.article_uuid') |
54 | 54 | ->join('category', 'category.category_uuid = articles.category_uuid', |
55 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left') |
|
56 | - ->where(['articles.article_id' => $id]); |
|
55 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left') |
|
56 | + ->where([ 'articles.article_id' => $id ]); |
|
57 | 57 | |
58 | 58 | return $this->selectWith($select)->current(); |
59 | 59 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | public function getLatest($limit = 50) |
62 | 62 | { |
63 | 63 | $select = $this->getSql()->select() |
64 | - ->join('articles', 'article_videos.article_uuid = articles.article_uuid', ['article_id', 'slug', 'published_at']) |
|
65 | - ->where(['articles.status' => 1]) |
|
66 | - ->order(['published_at' => 'desc']) |
|
64 | + ->join('articles', 'article_videos.article_uuid = articles.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
65 | + ->where([ 'articles.status' => 1 ]) |
|
66 | + ->order([ 'published_at' => 'desc' ]) |
|
67 | 67 | ->limit($limit); |
68 | 68 | |
69 | 69 | return $this->selectWith($select); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | $select = $this->getSql()->select() |
75 | 75 | ->join('articles', 'article_videos.article_uuid = articles.article_uuid') |
76 | - ->where(['articles.slug' => $slug]); |
|
76 | + ->where([ 'articles.slug' => $slug ]); |
|
77 | 77 | |
78 | 78 | return $this->selectWith($select)->current(); |
79 | 79 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Article\Mapper; |
5 | 5 | |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | public function getCategories($articleId) |
46 | 46 | { |
47 | 47 | $select = $this->getSql()->select() |
48 | - ->columns([]) |
|
49 | - ->join('category', 'category.category_uuid = articles.category_uuid', ['name', 'slug', 'category_id']) |
|
50 | - ->where(['articles.article_id' => $articleId]); |
|
48 | + ->columns([ ]) |
|
49 | + ->join('category', 'category.category_uuid = articles.category_uuid', [ 'name', 'slug', 'category_id' ]) |
|
50 | + ->where([ 'articles.article_id' => $articleId ]); |
|
51 | 51 | |
52 | 52 | return $this->selectWith($select); |
53 | 53 | } |
@@ -10,20 +10,20 @@ discard block |
||
10 | 10 | { |
11 | 11 | public function up() |
12 | 12 | { |
13 | - $this->table('article_events', ['id' => false]) |
|
14 | - ->addColumn('article_uuid', 'binary', ['limit' => 16]) |
|
13 | + $this->table('article_events', [ 'id' => false ]) |
|
14 | + ->addColumn('article_uuid', 'binary', [ 'limit' => 16 ]) |
|
15 | 15 | ->addColumn('title', 'text') |
16 | - ->addColumn('sub_title', 'text', ['null' => true]) |
|
16 | + ->addColumn('sub_title', 'text', [ 'null' => true ]) |
|
17 | 17 | ->addColumn('place_name', 'text') |
18 | 18 | ->addColumn('body', 'text') |
19 | 19 | ->addColumn('longitude', 'text') |
20 | 20 | ->addColumn('latitude', 'text') |
21 | - ->addColumn('featured_img', 'text', ['null' => true]) |
|
22 | - ->addColumn('main_img', 'text', ['null' => true]) |
|
21 | + ->addColumn('featured_img', 'text', [ 'null' => true ]) |
|
22 | + ->addColumn('main_img', 'text', [ 'null' => true ]) |
|
23 | 23 | ->addColumn('start_at', 'datetime') |
24 | 24 | ->addColumn('end_at', 'datetime') |
25 | - ->addColumn('event_url', 'text', ['null' => true]) |
|
26 | - ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
25 | + ->addColumn('event_url', 'text', [ 'null' => true ]) |
|
26 | + ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
27 | 27 | ->create(); |
28 | 28 | |
29 | 29 | // $this->insertDummyData(); |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | |
37 | 37 | private function insertDummyData() |
38 | 38 | { |
39 | - $ids = []; |
|
39 | + $ids = [ ]; |
|
40 | 40 | $rows = $this->fetchAll('select admin_user_uuid from admin_users;'); |
41 | - foreach($rows as $r){ |
|
42 | - $ids[] = $r['admin_user_uuid']; |
|
41 | + foreach ($rows as $r) { |
|
42 | + $ids[ ] = $r[ 'admin_user_uuid' ]; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $faker = Faker\Factory::create(); |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | $count = rand(25, 300); |
48 | 48 | |
49 | 49 | // Download N images and set it randomly to the events |
50 | - for($i = 0; $i < 5; $i++){ |
|
50 | + for ($i = 0; $i < 5; $i++) { |
|
51 | 51 | $image = $faker->image(); |
52 | 52 | $destination = $upload->getPath(basename($image)); |
53 | 53 | rename($image, $destination); |
54 | - $mainImg[] = substr($destination, strlen('/var/www/unfinished/public')); |
|
54 | + $mainImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); |
|
55 | 55 | |
56 | 56 | $image = $faker->image(); |
57 | 57 | $destination = $upload->getPath(basename($image)); |
58 | 58 | rename($image, $destination); |
59 | - $featuredImg[] = substr($destination, strlen('/var/www/unfinished/public')); |
|
59 | + $featuredImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); |
|
60 | 60 | } |
61 | 61 | |
62 | - for($i = 0; $i < $count; $i++){ |
|
62 | + for ($i = 0; $i < $count; $i++) { |
|
63 | 63 | $start = rand(1, 20); |
64 | 64 | $id = $faker->uuid; |
65 | 65 | $mysqluuid = (new Uuid($id))->toFormat(new Binary()); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | 'article_id' => $id, |
71 | 71 | 'slug' => strtolower(trim(preg_replace('~[^\pL\d]+~u', '-', $title), '-')), |
72 | 72 | 'status' => 1, |
73 | - 'admin_user_uuid' => $ids[array_rand($ids)], |
|
73 | + 'admin_user_uuid' => $ids[ array_rand($ids) ], |
|
74 | 74 | 'type' => ArticleType::EVENT |
75 | 75 | ]; |
76 | 76 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | 'longitude' => $faker->longitude, |
82 | 82 | 'latitude' => $faker->latitude, |
83 | 83 | 'place_name' => $faker->sentence(1), |
84 | - 'main_img' => $mainImg[array_rand($mainImg)], |
|
85 | - 'featured_img' => $featuredImg[array_rand($featuredImg)], |
|
84 | + 'main_img' => $mainImg[ array_rand($mainImg) ], |
|
85 | + 'featured_img' => $featuredImg[ array_rand($featuredImg) ], |
|
86 | 86 | 'start_at' => date("Y-m-d H:i:s", strtotime("+$start day +$start hours")), |
87 | 87 | 'end_at' => date("Y-m-d H:i:s", strtotime("+$start day +" . ($start + rand(1, 5)) . " hours")) |
88 | 88 | ]; |
@@ -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 Core\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 |