@@ -32,7 +32,7 @@ |
||
32 | 32 | */ |
33 | 33 | public function forHomepage() |
34 | 34 | { |
35 | - if(!$this->homepageCategories) { |
|
35 | + if (!$this->homepageCategories) { |
|
36 | 36 | $this->homepageCategories = $this->categoryService->getCategoriesWithPosts(true); |
37 | 37 | } |
38 | 38 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Category\Factory\Service; |
5 | 5 | |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __invoke(ContainerInterface $container): CategoryService |
22 | 22 | { |
23 | - $config = $container->get('config')['upload']; |
|
24 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
23 | + $config = $container->get('config')[ 'upload' ]; |
|
24 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
25 | 25 | |
26 | 26 | return new CategoryService( |
27 | 27 | $container->get(CategoryMapper::class), |
@@ -167,15 +167,13 @@ |
||
167 | 167 | // We don't want to force user to re-upload image on edit |
168 | 168 | if(!$data['face_img']) { |
169 | 169 | unset($data['face_img']); |
170 | - } |
|
171 | - else{ |
|
170 | + } else{ |
|
172 | 171 | $this->upload->deleteFile($user->face_img); |
173 | 172 | } |
174 | 173 | |
175 | 174 | if(!$data['profile_img']) { |
176 | 175 | unset($data['profile_img']); |
177 | - } |
|
178 | - else{ |
|
176 | + } else{ |
|
179 | 177 | $this->upload->deleteFile($user->profile_img); |
180 | 178 | } |
181 | 179 |
@@ -25,28 +25,28 @@ |
||
25 | 25 | /** |
26 | 26 | * |
27 | 27 | * |
28 | - * @var Bcrypt $crypt |
|
28 | + * @var Bcrypt $crypt |
|
29 | 29 | */ |
30 | 30 | private $crypt; |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * |
34 | 34 | * |
35 | - * @var AdminUsersMapper $adminUsersMapper |
|
35 | + * @var AdminUsersMapper $adminUsersMapper |
|
36 | 36 | */ |
37 | 37 | private $adminUsersMapper; |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * |
41 | 41 | * |
42 | - * @var AdminUserFilter $adminUserFilter |
|
42 | + * @var AdminUserFilter $adminUserFilter |
|
43 | 43 | */ |
44 | 44 | private $adminUserFilter; |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * |
48 | 48 | * |
49 | - * @var Upload $upload |
|
49 | + * @var Upload $upload |
|
50 | 50 | */ |
51 | 51 | private $upload; |
52 | 52 |
@@ -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 Core\Service; |
6 | 6 | |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function loginUser($email, $password) |
83 | 83 | { |
84 | - if(!$email || !$password) { |
|
84 | + if (!$email || !$password) { |
|
85 | 85 | throw new \Exception('Both email and password are required.', 400); |
86 | 86 | } |
87 | 87 | |
88 | 88 | $user = $this->adminUsersMapper->getByEmail($email); |
89 | 89 | |
90 | - if(!$user) { |
|
90 | + if (!$user) { |
|
91 | 91 | throw new \Exception('User does not exist.'); |
92 | 92 | } |
93 | 93 | |
94 | - if(!$this->crypt->verify($password, $user->password)) { |
|
94 | + if (!$this->crypt->verify($password, $user->password)) { |
|
95 | 95 | throw new \Exception('Password does not match.'); |
96 | 96 | } |
97 | 97 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | { |
136 | 136 | $filter = $this->adminUserFilter->getInputFilter()->setData($data); |
137 | 137 | |
138 | - if(!$filter->isValid()) { |
|
138 | + if (!$filter->isValid()) { |
|
139 | 139 | throw new FilterException($filter->getMessages()); |
140 | 140 | } |
141 | 141 | |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | 'profile_img' => $this->upload->uploadImage($data, 'profile_img') |
145 | 145 | ]; |
146 | 146 | |
147 | - unset($data['confirm_password']); |
|
148 | - $data['password'] = $this->crypt->create($data['password']); |
|
149 | - $data['admin_user_id'] = Uuid::uuid1()->toString(); |
|
150 | - $data['admin_user_uuid'] = (new MysqlUuid($data['admin_user_id']))->toFormat(new Binary); |
|
147 | + unset($data[ 'confirm_password' ]); |
|
148 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); |
|
149 | + $data[ 'admin_user_id' ] = Uuid::uuid1()->toString(); |
|
150 | + $data[ 'admin_user_uuid' ] = (new MysqlUuid($data[ 'admin_user_id' ]))->toFormat(new Binary); |
|
151 | 151 | |
152 | 152 | return $this->adminUsersMapper->insert($data); |
153 | 153 | } |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | $filter = $this->adminUserFilter->getInputFilter()->setData($data); |
162 | 162 | |
163 | 163 | // we dont want to force user to enter the password again |
164 | - if($data['password'] == '') { |
|
164 | + if ($data[ 'password' ] == '') { |
|
165 | 165 | $filter->remove('password'); |
166 | 166 | $filter->remove('confirm_password'); |
167 | 167 | } |
168 | 168 | |
169 | 169 | // if we want to keep same email |
170 | - if($user->email == $data['email']) { |
|
170 | + if ($user->email == $data[ 'email' ]) { |
|
171 | 171 | $filter->remove('email'); |
172 | 172 | } |
173 | 173 | |
174 | - if(!$filter->isValid()) { |
|
174 | + if (!$filter->isValid()) { |
|
175 | 175 | throw new FilterException($filter->getMessages()); |
176 | 176 | } |
177 | 177 | |
@@ -181,26 +181,26 @@ discard block |
||
181 | 181 | ]; |
182 | 182 | |
183 | 183 | // We don't want to force user to re-upload image on edit |
184 | - if(!$data['face_img']) { |
|
185 | - unset($data['face_img']); |
|
184 | + if (!$data[ 'face_img' ]) { |
|
185 | + unset($data[ 'face_img' ]); |
|
186 | 186 | } |
187 | - else{ |
|
187 | + else { |
|
188 | 188 | $this->upload->deleteFile($user->face_img); |
189 | 189 | } |
190 | 190 | |
191 | - if(!$data['profile_img']) { |
|
192 | - unset($data['profile_img']); |
|
191 | + if (!$data[ 'profile_img' ]) { |
|
192 | + unset($data[ 'profile_img' ]); |
|
193 | 193 | } |
194 | - else{ |
|
194 | + else { |
|
195 | 195 | $this->upload->deleteFile($user->profile_img); |
196 | 196 | } |
197 | 197 | |
198 | - if(isset($data['password'])) { |
|
199 | - unset($data['confirm_password']); |
|
200 | - $data['password'] = $this->crypt->create($data['password']); |
|
198 | + if (isset($data[ 'password' ])) { |
|
199 | + unset($data[ 'confirm_password' ]); |
|
200 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); |
|
201 | 201 | } |
202 | 202 | |
203 | - return $this->adminUsersMapper->update($data, ['admin_user_id' => $userId]); |
|
203 | + return $this->adminUsersMapper->update($data, [ 'admin_user_id' => $userId ]); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function delete($userId) |
214 | 214 | { |
215 | - if(!($adminUser = $this->getUser($userId))) { |
|
215 | + if (!($adminUser = $this->getUser($userId))) { |
|
216 | 216 | throw new \Exception('Admin user not found.'); |
217 | 217 | } |
218 | 218 | |
219 | 219 | $this->upload->deleteFile($adminUser->face_img); |
220 | 220 | $this->upload->deleteFile($adminUser->profile_img); |
221 | 221 | |
222 | - return (bool)$this->adminUsersMapper->delete(['admin_user_id' => $userId]); |
|
222 | + return (bool) $this->adminUsersMapper->delete([ 'admin_user_id' => $userId ]); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Category\Service; |
5 | 5 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function getCategoryBySlug($urlSlug) |
78 | 78 | { |
79 | - return $this->categoryMapper->select(['slug' => $urlSlug])->current(); |
|
79 | + return $this->categoryMapper->select([ 'slug' => $urlSlug ])->current(); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | { |
90 | 90 | $filter = $this->categoryFilter->getInputFilter()->setData($data); |
91 | 91 | |
92 | - if(!$filter->isValid()) { |
|
92 | + if (!$filter->isValid()) { |
|
93 | 93 | throw new FilterException($filter->getMessages()); |
94 | 94 | } |
95 | 95 | |
96 | 96 | $values = $filter->getValues(); |
97 | - $values['category_id'] = Uuid::uuid1()->toString(); |
|
98 | - $values['category_uuid'] = (new MysqlUuid($values['category_id']))->toFormat(new Binary); |
|
99 | - $values['main_img'] = $this->upload->uploadImage($data, 'main_img'); |
|
97 | + $values[ 'category_id' ] = Uuid::uuid1()->toString(); |
|
98 | + $values[ 'category_uuid' ] = (new MysqlUuid($values[ 'category_id' ]))->toFormat(new Binary); |
|
99 | + $values[ 'main_img' ] = $this->upload->uploadImage($data, 'main_img'); |
|
100 | 100 | |
101 | 101 | $this->categoryMapper->insert($values); |
102 | 102 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | $filter = $this->categoryFilter->getInputFilter()->setData($data); |
119 | 119 | |
120 | - if(!$filter->isValid()) { |
|
120 | + if (!$filter->isValid()) { |
|
121 | 121 | throw new FilterException($filter->getMessages()); |
122 | 122 | } |
123 | 123 | |
@@ -126,14 +126,14 @@ discard block |
||
126 | 126 | ]; |
127 | 127 | |
128 | 128 | // We don't want to force user to re-upload image on edit |
129 | - if(!$values['main_img']) { |
|
130 | - unset($values['main_img']); |
|
129 | + if (!$values[ 'main_img' ]) { |
|
130 | + unset($values[ 'main_img' ]); |
|
131 | 131 | } |
132 | - else{ |
|
132 | + else { |
|
133 | 133 | $this->upload->deleteFile($oldCategory->main_img); |
134 | 134 | } |
135 | 135 | |
136 | - $this->categoryMapper->update($values, ['category_id' => $categoryId]); |
|
136 | + $this->categoryMapper->update($values, [ 'category_id' => $categoryId ]); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | $this->upload->deleteFile($category->main_img); |
150 | 150 | |
151 | - return (bool)$this->categoryMapper->delete(['category_id' => $categoryId]); |
|
151 | + return (bool) $this->categoryMapper->delete([ 'category_id' => $categoryId ]); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | { |
173 | 173 | $categories = $this->categoryMapper->getWeb(7, null, $inHomepage, $inCategoryList)->toArray(); |
174 | 174 | |
175 | - foreach($categories as $ctn => $category) { |
|
176 | - $select = $this->categoryMapper->getCategoryPostsSelect($category['category_id'], 4); |
|
175 | + foreach ($categories as $ctn => $category) { |
|
176 | + $select = $this->categoryMapper->getCategoryPostsSelect($category[ 'category_id' ], 4); |
|
177 | 177 | $posts = $this->categoryMapper->selectWith($select)->toArray(); |
178 | - $categories[$ctn]['posts'] = $posts; |
|
178 | + $categories[ $ctn ][ 'posts' ] = $posts; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | return $categories; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function getCategories($inCategoryList = null) |
191 | 191 | { |
192 | - return $this->categoryMapper->getWeb(null, ['name' => 'asc'], null, $inCategoryList); |
|
192 | + return $this->categoryMapper->getWeb(null, [ 'name' => 'asc' ], null, $inCategoryList); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -128,8 +128,7 @@ |
||
128 | 128 | // We don't want to force user to re-upload image on edit |
129 | 129 | if(!$values['main_img']) { |
130 | 130 | unset($values['main_img']); |
131 | - } |
|
132 | - else{ |
|
131 | + } else{ |
|
133 | 132 | $this->upload->deleteFile($oldCategory->main_img); |
134 | 133 | } |
135 | 134 |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | /** |
165 | 165 | * Return categories with posts/articles |
166 | 166 | * |
167 | - * @param null $inHomepage |
|
167 | + * @param boolean $inHomepage |
|
168 | 168 | * @param null $inCategoryList |
169 | 169 | * @return mixed |
170 | 170 | */ |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | /** |
185 | 185 | * Return categories posts/articles |
186 | 186 | * |
187 | - * @param null $inCategoryList |
|
187 | + * @param boolean $inCategoryList |
|
188 | 188 | * @return null|\Zend\Db\ResultSet\ResultSetInterface |
189 | 189 | */ |
190 | 190 | public function getCategories($inCategoryList = null) |
@@ -12,7 +12,6 @@ |
||
12 | 12 | /** |
13 | 13 | * Fetches a list of ArticleEntity models. |
14 | 14 | * |
15 | - * @param array $params |
|
16 | 15 | * @return ArrayObject |
17 | 16 | */ |
18 | 17 | public function fetchAllArticles($page, $limit); |
@@ -16,21 +16,21 @@ |
||
16 | 16 | /** |
17 | 17 | * |
18 | 18 | * |
19 | - * @var Template |
|
19 | + * @var Template |
|
20 | 20 | */ |
21 | 21 | private $template; |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * |
25 | 25 | * |
26 | - * @var Router |
|
26 | + * @var Router |
|
27 | 27 | */ |
28 | 28 | private $router; |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * |
32 | 32 | * |
33 | - * @var MenuService |
|
33 | + * @var MenuService |
|
34 | 34 | */ |
35 | 35 | private $menuService; |
36 | 36 |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | ); |
54 | 54 | } |
55 | 55 | |
56 | - public function edit($errors = []) |
|
56 | + public function edit($errors = [ ]) |
|
57 | 57 | { |
58 | 58 | $id = $this->request->getAttribute('id'); |
59 | 59 | $item = $this->menuService->get($id); |
60 | 60 | |
61 | - if($this->request->getParsedBody()) { |
|
62 | - $item = (object)($this->request->getParsedBody() + (array)$item); |
|
61 | + if ($this->request->getParsedBody()) { |
|
62 | + $item = (object) ($this->request->getParsedBody() + (array) $item); |
|
63 | 63 | $item->menu_id = $id; |
64 | 64 | } |
65 | 65 | |
@@ -78,36 +78,36 @@ discard block |
||
78 | 78 | |
79 | 79 | public function save() |
80 | 80 | { |
81 | - try{ |
|
81 | + try { |
|
82 | 82 | $id = $this->request->getAttribute('id'); |
83 | 83 | $data = $this->request->getParsedBody(); |
84 | 84 | |
85 | - if($id) { |
|
85 | + if ($id) { |
|
86 | 86 | $this->menuService->updateMenuItem($data, $id); |
87 | 87 | } |
88 | - else{ |
|
88 | + else { |
|
89 | 89 | $this->menuService->addMenuItem($data); |
90 | 90 | } |
91 | 91 | |
92 | 92 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.menu')); |
93 | 93 | } |
94 | - catch(FilterException $fe){ |
|
94 | + catch (FilterException $fe) { |
|
95 | 95 | return $this->edit($fe->getArrayMessages()); |
96 | 96 | } |
97 | - catch(\Exception $e){ |
|
97 | + catch (\Exception $e) { |
|
98 | 98 | throw $e; |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | 102 | public function delete() |
103 | 103 | { |
104 | - try{ |
|
104 | + try { |
|
105 | 105 | $id = $this->request->getAttribute('id'); |
106 | 106 | $this->menuService->delete($id); |
107 | 107 | |
108 | 108 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.menu')); |
109 | 109 | } |
110 | - catch(\Exception $e){ |
|
110 | + catch (\Exception $e) { |
|
111 | 111 | throw $e; |
112 | 112 | } |
113 | 113 | } |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | public function updateOrder() |
116 | 116 | { |
117 | 117 | $data = $this->request->getParsedBody(); |
118 | - $menuOrder = isset($data['order']) ? json_decode($data['order']) : []; |
|
118 | + $menuOrder = isset($data[ 'order' ]) ? json_decode($data[ 'order' ]) : [ ]; |
|
119 | 119 | $status = $this->menuService->updateMenuOrder($menuOrder); |
120 | 120 | |
121 | - return new JsonResponse(['status' => $status]); |
|
121 | + return new JsonResponse([ 'status' => $status ]); |
|
122 | 122 | } |
123 | 123 | } |
@@ -84,17 +84,14 @@ discard block |
||
84 | 84 | |
85 | 85 | if($id) { |
86 | 86 | $this->menuService->updateMenuItem($data, $id); |
87 | - } |
|
88 | - else{ |
|
87 | + } else{ |
|
89 | 88 | $this->menuService->addMenuItem($data); |
90 | 89 | } |
91 | 90 | |
92 | 91 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.menu')); |
93 | - } |
|
94 | - catch(FilterException $fe){ |
|
92 | + } catch(FilterException $fe){ |
|
95 | 93 | return $this->edit($fe->getArrayMessages()); |
96 | - } |
|
97 | - catch(\Exception $e){ |
|
94 | + } catch(\Exception $e){ |
|
98 | 95 | throw $e; |
99 | 96 | } |
100 | 97 | } |
@@ -106,8 +103,7 @@ discard block |
||
106 | 103 | $this->menuService->delete($id); |
107 | 104 | |
108 | 105 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.menu')); |
109 | - } |
|
110 | - catch(\Exception $e){ |
|
106 | + } catch(\Exception $e){ |
|
111 | 107 | throw $e; |
112 | 108 | } |
113 | 109 | } |
@@ -29,16 +29,16 @@ |
||
29 | 29 | |
30 | 30 | public function getHeaderMenu() |
31 | 31 | { |
32 | - return $this->menuService->getNestedAll(true, ['is_in_header' => true]); |
|
32 | + return $this->menuService->getNestedAll(true, [ 'is_in_header' => true ]); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function getFooterMenu() |
36 | 36 | { |
37 | - return $this->menuService->getNestedAll(true, ['is_in_footer' => true]); |
|
37 | + return $this->menuService->getNestedAll(true, [ 'is_in_footer' => true ]); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function getSideMenu() |
41 | 41 | { |
42 | - return $this->menuService->getNestedAll(true, ['is_in_side' => true]); |
|
42 | + return $this->menuService->getNestedAll(true, [ 'is_in_side' => true ]); |
|
43 | 43 | } |
44 | 44 | } |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | |
21 | 21 | public function getInputFilter() |
22 | 22 | { |
23 | - if(!$this->inputFilter) { |
|
23 | + if (!$this->inputFilter) { |
|
24 | 24 | $inputFilter = new InputFilter(); |
25 | 25 | |
26 | 26 | $inputFilter->add( |
27 | 27 | [ |
28 | 28 | 'name' => 'title', |
29 | 29 | 'required' => true, |
30 | - 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], |
|
30 | + 'filters' => [ [ 'name' => 'StripTags' ], [ 'name' => 'StringTrim' ] ], |
|
31 | 31 | 'validators' => [ |
32 | - ['name' => 'NotEmpty'], |
|
33 | - ['name' => 'StringLength', 'options' => ['max' => '255']], |
|
32 | + [ 'name' => 'NotEmpty' ], |
|
33 | + [ 'name' => 'StringLength', 'options' => [ 'max' => '255' ] ], |
|
34 | 34 | ], |
35 | 35 | ] |
36 | 36 | ); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | [ |
40 | 40 | 'name' => 'href', |
41 | 41 | 'required' => false, |
42 | - 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']] |
|
42 | + 'filters' => [ [ 'name' => 'StripTags' ], [ 'name' => 'StringTrim' ] ] |
|
43 | 43 | ] |
44 | 44 | ); |
45 | 45 | |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | [ |
48 | 48 | 'name' => 'article_id', |
49 | 49 | 'required' => false, |
50 | - 'filters' => [['name' => 'Null']], |
|
50 | + 'filters' => [ [ 'name' => 'Null' ] ], |
|
51 | 51 | 'validators' => [ |
52 | - ['name' => RecordExists::class, 'options' => ['table' => 'articles', 'field' => 'article_id', 'adapter' => $this->db]] |
|
52 | + [ 'name' => RecordExists::class, 'options' => [ 'table' => 'articles', 'field' => 'article_id', 'adapter' => $this->db ] ] |
|
53 | 53 | ] |
54 | 54 | ] |
55 | 55 | ); |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | [ |
59 | 59 | 'name' => 'category_id', |
60 | 60 | 'required' => false, |
61 | - 'filters' => [['name' => 'Null']], |
|
61 | + 'filters' => [ [ 'name' => 'Null' ] ], |
|
62 | 62 | 'validators' => [ |
63 | - ['name' => RecordExists::class, 'options' => ['table' => 'category', 'field' => 'category_id', 'adapter' => $this->db]] |
|
63 | + [ 'name' => RecordExists::class, 'options' => [ 'table' => 'category', 'field' => 'category_id', 'adapter' => $this->db ] ] |
|
64 | 64 | ] |
65 | 65 | ] |
66 | 66 | ); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | [ |
70 | 70 | 'name' => 'is_active', |
71 | 71 | 'required' => false, |
72 | - 'filters' => [['name' => 'Boolean']] |
|
72 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
73 | 73 | ] |
74 | 74 | ); |
75 | 75 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | [ |
78 | 78 | 'name' => 'is_in_header', |
79 | 79 | 'required' => false, |
80 | - 'filters' => [['name' => 'Boolean']] |
|
80 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
81 | 81 | ] |
82 | 82 | ); |
83 | 83 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | [ |
86 | 86 | 'name' => 'is_in_footer', |
87 | 87 | 'required' => false, |
88 | - 'filters' => [['name' => 'Boolean']] |
|
88 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
89 | 89 | ] |
90 | 90 | ); |
91 | 91 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | [ |
94 | 94 | 'name' => 'is_in_side', |
95 | 95 | 'required' => false, |
96 | - 'filters' => [['name' => 'Boolean']] |
|
96 | + 'filters' => [ [ 'name' => 'Boolean' ] ] |
|
97 | 97 | ] |
98 | 98 | ); |
99 | 99 |
@@ -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; |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | ->join('articles', 'article_events.article_uuid = articles.article_uuid') |
56 | 56 | ->join( |
57 | 57 | 'category', 'category.category_uuid = articles.category_uuid', |
58 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left' |
|
58 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left' |
|
59 | 59 | ) |
60 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id'], 'left') |
|
61 | - ->where(['articles.article_id' => $id]); |
|
60 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id' ], 'left') |
|
61 | + ->where([ 'articles.article_id' => $id ]); |
|
62 | 62 | |
63 | 63 | return $this->selectWith($select)->current(); |
64 | 64 | } |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | ->join('articles', 'article_events.article_uuid = articles.article_uuid') |
70 | 70 | ->join( |
71 | 71 | 'category', 'category.category_uuid = articles.category_uuid', |
72 | - ['category_slug' => 'slug', 'category_name' => 'name', 'category_id'], 'left' |
|
72 | + [ 'category_slug' => 'slug', 'category_name' => 'name', 'category_id' ], 'left' |
|
73 | 73 | ) |
74 | - ->where(['articles.slug' => $slug]); |
|
74 | + ->where([ 'articles.slug' => $slug ]); |
|
75 | 75 | |
76 | 76 | return $this->selectWith($select)->current(); |
77 | 77 | } |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | public function getLatest($limit = 50) |
80 | 80 | { |
81 | 81 | $select = $this->getSql()->select() |
82 | - ->join('articles', 'article_events.article_uuid = articles.article_uuid', ['article_id', 'slug', 'published_at']) |
|
83 | - ->where(['articles.status' => 1]) |
|
84 | - ->order(['published_at' => 'desc']) |
|
82 | + ->join('articles', 'article_events.article_uuid = articles.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
83 | + ->where([ 'articles.status' => 1 ]) |
|
84 | + ->order([ 'published_at' => 'desc' ]) |
|
85 | 85 | ->limit($limit); |
86 | 86 | |
87 | 87 | return $this->selectWith($select); |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | public function getFuture() |
91 | 91 | { |
92 | 92 | $select = $this->getSql()->select() |
93 | - ->where(['articles.status' => 1]) |
|
94 | - ->join('articles', 'articles.article_uuid = article_events.article_uuid', ['article_id', 'slug', 'published_at']) |
|
93 | + ->where([ 'articles.status' => 1 ]) |
|
94 | + ->join('articles', 'articles.article_uuid = article_events.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
95 | 95 | ->order(new Expression('rand()')); |
96 | 96 | |
97 | 97 | $select->where->greaterThanOrEqualTo('end_at', date('Y-m-d H:i:s')); |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | public function getPastSelect() |
103 | 103 | { |
104 | 104 | $select = $this->getSql()->select() |
105 | - ->where(['articles.status' => 1]) |
|
106 | - ->join('articles', 'articles.article_uuid = article_events.article_uuid', ['article_id', 'slug', 'published_at']) |
|
107 | - ->order(['start_at' => 'desc']); |
|
105 | + ->where([ 'articles.status' => 1 ]) |
|
106 | + ->join('articles', 'articles.article_uuid = article_events.article_uuid', [ 'article_id', 'slug', 'published_at' ]) |
|
107 | + ->order([ 'start_at' => 'desc' ]); |
|
108 | 108 | |
109 | 109 | $select->where->lessThan('end_at', date('Y-m-d H:i:s')); |
110 | 110 |