@@ -11,19 +11,19 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | public function getImages($faker, $type = 'people', $width = 400, $height = 400) |
| 13 | 13 | { |
| 14 | - $images = []; |
|
| 14 | + $images = [ ]; |
|
| 15 | 15 | $conf = include __DIR__ . "/../../../config/autoload/local.php"; |
| 16 | - $p = $conf['upload']['public_path']; |
|
| 16 | + $p = $conf[ 'upload' ][ 'public_path' ]; |
|
| 17 | 17 | $upload = new Upload($p, ''); |
| 18 | 18 | |
| 19 | - for($i = 0; $i < 5; $i++) { |
|
| 19 | + for ($i = 0; $i < 5; $i++) { |
|
| 20 | 20 | $filename = md5(rand()) . '.jpg'; |
| 21 | - $path = $p . $filename[0] . '/' . $filename[1] . '/' . $filename[2] . '/' . $filename; |
|
| 21 | + $path = $p . $filename[ 0 ] . '/' . $filename[ 1 ] . '/' . $filename[ 2 ] . '/' . $filename; |
|
| 22 | 22 | $upload->getPath($filename); // create sub folders |
| 23 | 23 | $img = file_get_contents($faker->imageUrl(400, 400, $type)); |
| 24 | 24 | file_put_contents($path, $img); |
| 25 | 25 | |
| 26 | - $images[] = $upload->getWebPath($filename); |
|
| 26 | + $images[ ] = $upload->getWebPath($filename); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | return $images; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $faceImages = $this->getImages($faker, 'people'); |
| 38 | 38 | $profileImages = $this->getImages($faker, 'fashion'); |
| 39 | 39 | |
| 40 | - for($i = 0; $i < $count; $i++) { |
|
| 40 | + for ($i = 0; $i < $count; $i++) { |
|
| 41 | 41 | $id = $faker->uuid; |
| 42 | 42 | $mysqluuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
| 43 | 43 | |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | 'status' => rand(0, 1), |
| 52 | 52 | 'last_login' => rand(0, 10) === 7 ? null : $faker->dateTimeBetween('-10 days', 'now')->format('Y-m-d H:i:s'), |
| 53 | 53 | 'created_at' => $faker->dateTimeBetween('-20 days', '-10 days')->format('Y-m-d H:i:s'), |
| 54 | - 'face_img' => $faceImages[rand(0, (count($faceImages) - 1))], |
|
| 55 | - 'profile_img' => $profileImages[rand(0, (count($profileImages) - 1))] |
|
| 54 | + 'face_img' => $faceImages[ rand(0, (count($faceImages) - 1)) ], |
|
| 55 | + 'profile_img' => $profileImages[ rand(0, (count($profileImages) - 1)) ] |
|
| 56 | 56 | ]; |
| 57 | 57 | |
| 58 | 58 | $users->insert($data)->save(); |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | $category = $this->table('category'); |
| 12 | 12 | $count = rand(5, 10); |
| 13 | 13 | |
| 14 | - for($i = 0; $i < $count; $i++) { |
|
| 14 | + for ($i = 0; $i < $count; $i++) { |
|
| 15 | 15 | $id = $faker->uuid; |
| 16 | 16 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
| 17 | 17 | $categoryName = $faker->name; |
@@ -8,21 +8,21 @@ discard block |
||
| 8 | 8 | { |
| 9 | 9 | public function up() |
| 10 | 10 | { |
| 11 | - $this->table('admin_users', ['id' => false, 'primary_key' => 'admin_user_uuid']) |
|
| 12 | - ->addColumn('admin_user_uuid', 'binary', ['limit' => 16]) |
|
| 11 | + $this->table('admin_users', [ 'id' => false, 'primary_key' => 'admin_user_uuid' ]) |
|
| 12 | + ->addColumn('admin_user_uuid', 'binary', [ 'limit' => 16 ]) |
|
| 13 | 13 | ->addColumn('admin_user_id', 'text') |
| 14 | 14 | ->addColumn('first_name', 'text') |
| 15 | 15 | ->addColumn('last_name', 'text') |
| 16 | - ->addColumn('introduction', 'text', ['null' => true]) |
|
| 17 | - ->addColumn('biography', 'text', ['null' => true]) |
|
| 18 | - ->addColumn('email', 'string', ['limit' => 128]) |
|
| 19 | - ->addColumn('password', 'char', ['limit' => 60]) |
|
| 20 | - ->addColumn('status', 'integer', ['default' => 0])// 0 => not active, 1 = active |
|
| 21 | - ->addColumn('face_img', 'text', ['null' => true]) |
|
| 22 | - ->addColumn('profile_img', 'text', ['null' => true]) |
|
| 23 | - ->addColumn('created_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP']) |
|
| 24 | - ->addColumn('last_login', 'datetime', ['null' => true]) |
|
| 25 | - ->addIndex(['email'], ['name' => 'email_INDEX']) |
|
| 16 | + ->addColumn('introduction', 'text', [ 'null' => true ]) |
|
| 17 | + ->addColumn('biography', 'text', [ 'null' => true ]) |
|
| 18 | + ->addColumn('email', 'string', [ 'limit' => 128 ]) |
|
| 19 | + ->addColumn('password', 'char', [ 'limit' => 60 ]) |
|
| 20 | + ->addColumn('status', 'integer', [ 'default' => 0 ])// 0 => not active, 1 = active |
|
| 21 | + ->addColumn('face_img', 'text', [ 'null' => true ]) |
|
| 22 | + ->addColumn('profile_img', 'text', [ 'null' => true ]) |
|
| 23 | + ->addColumn('created_at', 'datetime', [ 'default' => 'CURRENT_TIMESTAMP' ]) |
|
| 24 | + ->addColumn('last_login', 'datetime', [ 'null' => true ]) |
|
| 25 | + ->addIndex([ 'email' ], [ 'name' => 'email_INDEX' ]) |
|
| 26 | 26 | ->create(); |
| 27 | 27 | |
| 28 | 28 | // Insert one default admin user with password testtest |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | private function getImage($faker, $type = 'people', $width = 400, $height = 400) |
| 52 | 52 | { |
| 53 | 53 | $conf = include __DIR__ . "/../../../config/autoload/local.php"; |
| 54 | - $p = $conf['upload']['public_path']; |
|
| 54 | + $p = $conf[ 'upload' ][ 'public_path' ]; |
|
| 55 | 55 | $upload = new \UploadHelper\Upload($p, ''); |
| 56 | 56 | $filename = md5(rand()) . '.jpg'; |
| 57 | - $path = $p . $filename[0] . '/' . $filename[1] . '/' . $filename[2] . '/' . $filename; |
|
| 57 | + $path = $p . $filename[ 0 ] . '/' . $filename[ 1 ] . '/' . $filename[ 2 ] . '/' . $filename; |
|
| 58 | 58 | $upload->getPath($filename); // create sub folders |
| 59 | 59 | $img = file_get_contents($faker->imageUrl(400, 400, $type)); |
| 60 | 60 | file_put_contents($path, $img); |
@@ -7,7 +7,6 @@ |
||
| 7 | 7 | use Zend\Db\Adapter\AdapterAwareInterface; |
| 8 | 8 | use Zend\Db\TableGateway\AbstractTableGateway; |
| 9 | 9 | use Zend\Db\Sql\Delete; |
| 10 | -use Zend\Db\Sql\Insert; |
|
| 11 | 10 | |
| 12 | 11 | /** |
| 13 | 12 | * Class ArticleMapper. |
@@ -44,9 +44,9 @@ |
||
| 44 | 44 | public function getCategories($articleId) |
| 45 | 45 | { |
| 46 | 46 | $select = $this->getSql()->select() |
| 47 | - ->columns([]) |
|
| 48 | - ->join('category', 'category.category_uuid = articles.category_uuid', ['name', 'slug', 'category_id']) |
|
| 49 | - ->where(['articles.article_id' => $articleId]); |
|
| 47 | + ->columns([ ]) |
|
| 48 | + ->join('category', 'category.category_uuid = articles.category_uuid', [ 'name', 'slug', 'category_id' ]) |
|
| 49 | + ->where([ 'articles.article_id' => $articleId ]); |
|
| 50 | 50 | |
| 51 | 51 | return $this->selectWith($select); |
| 52 | 52 | } |
@@ -63,6 +63,9 @@ |
||
| 63 | 63 | return $this->getPagination($select, $page, $limit); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | + /** |
|
| 67 | + * @param integer $limit |
|
| 68 | + */ |
|
| 66 | 69 | public function fetchLatest($limit) |
| 67 | 70 | { |
| 68 | 71 | return $this->articleEventsMapper->getLatest($limit); |
@@ -101,15 +101,15 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | $article = $articleFilter->getValues(); |
| 103 | 103 | $article += [ |
| 104 | - 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']), |
|
| 104 | + 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]), |
|
| 105 | 105 | 'type' => ArticleType::EVENT, |
| 106 | 106 | 'article_id' => $id, |
| 107 | 107 | 'article_uuid' => $uuId |
| 108 | 108 | ]; |
| 109 | - unset($article['admin_user_id']); |
|
| 109 | + unset($article[ 'admin_user_id' ]); |
|
| 110 | 110 | |
| 111 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 112 | - unset($article['category_id']); |
|
| 111 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 112 | + unset($article[ 'category_id' ]); |
|
| 113 | 113 | |
| 114 | 114 | $event = $eventFilter->getValues() + [ |
| 115 | 115 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -131,31 +131,31 @@ discard block |
||
| 131 | 131 | throw new FilterException($articleFilter->getMessages() + $eventFilter->getMessages()); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - $article = $articleFilter->getValues() + ['article_uuid' => $oldArticle->article_uuid]; |
|
| 134 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $oldArticle->article_uuid ]; |
|
| 135 | 135 | $event = $eventFilter->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['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']); |
|
| 141 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 142 | - unset($article['category_id'], $article['admin_user_id']); |
|
| 140 | + $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]); |
|
| 141 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 142 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
| 143 | 143 | |
| 144 | 144 | // We don't want to force user to re-upload image on edit |
| 145 | - if (!$event['featured_img']) { |
|
| 146 | - unset($event['featured_img']); |
|
| 145 | + if (!$event[ 'featured_img' ]) { |
|
| 146 | + unset($event[ 'featured_img' ]); |
|
| 147 | 147 | } else { |
| 148 | 148 | $this->upload->deleteFile($oldArticle->featured_img); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if (!$event['main_img']) { |
|
| 152 | - unset($event['main_img']); |
|
| 151 | + if (!$event[ 'main_img' ]) { |
|
| 152 | + unset($event[ 'main_img' ]); |
|
| 153 | 153 | } else { |
| 154 | 154 | $this->upload->deleteFile($oldArticle->main_img); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
| 158 | - $this->articleEventsMapper->update($event, ['article_uuid' => $article['article_uuid']]); |
|
| 157 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 158 | + $this->articleEventsMapper->update($event, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | public function deleteArticle($id) |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | $this->upload->deleteFile($event->main_img); |
| 170 | 170 | $this->upload->deleteFile($event->featured_img); |
| 171 | - $this->articleEventsMapper->delete(['article_uuid' => $event->article_uuid]); |
|
| 171 | + $this->articleEventsMapper->delete([ 'article_uuid' => $event->article_uuid ]); |
|
| 172 | 172 | $this->delete($event->article_uuid); |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -203,6 +203,9 @@ |
||
| 203 | 203 | return $this->articleMapper->getCategories($articleId); |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | + /** |
|
| 207 | + * @param integer $limit |
|
| 208 | + */ |
|
| 206 | 209 | public function getLatestWeb($limit) |
| 207 | 210 | { |
| 208 | 211 | return $this->articlePostsMapper->getLatest($limit); |
@@ -137,19 +137,19 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $article = $articleFilter->getValues(); |
| 139 | 139 | $article += [ |
| 140 | - 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']), |
|
| 140 | + 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]), |
|
| 141 | 141 | 'type' => ArticleType::POST, |
| 142 | 142 | 'article_id' => $id, |
| 143 | 143 | 'article_uuid' => $uuId |
| 144 | 144 | ]; |
| 145 | 145 | |
| 146 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 147 | - unset($article['category_id'], $article['admin_user_id']); |
|
| 146 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 147 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
| 148 | 148 | |
| 149 | 149 | $post = $postFilter->getValues() + [ |
| 150 | 150 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
| 151 | 151 | 'main_img' => $this->upload->uploadImage($data, 'main_img'), |
| 152 | - 'article_uuid' => $article['article_uuid'] |
|
| 152 | + 'article_uuid' => $article[ 'article_uuid' ] |
|
| 153 | 153 | ]; |
| 154 | 154 | |
| 155 | 155 | $this->articleMapper->insert($article); |
@@ -166,31 +166,31 @@ discard block |
||
| 166 | 166 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $article = $articleFilter->getValues() + ['article_uuid' => $oldArticle->article_uuid]; |
|
| 169 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $oldArticle->article_uuid ]; |
|
| 170 | 170 | $post = $postFilter->getValues() + [ |
| 171 | 171 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
| 172 | 172 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
| 173 | 173 | ]; |
| 174 | 174 | |
| 175 | - $article['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']); |
|
| 176 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 177 | - unset($article['category_id'], $article['admin_user_id']); |
|
| 175 | + $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]); |
|
| 176 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 177 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
| 178 | 178 | |
| 179 | 179 | // We don't want to force user to re-upload image on edit |
| 180 | - if (!$post['featured_img']) { |
|
| 181 | - unset($post['featured_img']); |
|
| 180 | + if (!$post[ 'featured_img' ]) { |
|
| 181 | + unset($post[ 'featured_img' ]); |
|
| 182 | 182 | } else { |
| 183 | 183 | $this->upload->deleteFile($oldArticle->featured_img); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if (!$post['main_img']) { |
|
| 187 | - unset($post['main_img']); |
|
| 186 | + if (!$post[ 'main_img' ]) { |
|
| 187 | + unset($post[ 'main_img' ]); |
|
| 188 | 188 | } else { |
| 189 | 189 | $this->upload->deleteFile($oldArticle->main_img); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
| 193 | - $this->articlePostsMapper->update($post, ['article_uuid' => $article['article_uuid']]); |
|
| 192 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 193 | + $this->articlePostsMapper->update($post, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | public function deleteArticle($id) |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $this->upload->deleteFile($post->main_img); |
| 205 | 205 | $this->upload->deleteFile($post->featured_img); |
| 206 | - $this->articlePostsMapper->delete(['article_uuid' => $post->article_uuid]); |
|
| 206 | + $this->articlePostsMapper->delete([ 'article_uuid' => $post->article_uuid ]); |
|
| 207 | 207 | $this->delete($post->article_uuid); |
| 208 | 208 | } |
| 209 | 209 | |
@@ -91,6 +91,9 @@ |
||
| 91 | 91 | return $this->getPagination($select, $page, $limit); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | + /** |
|
| 95 | + * @param integer $limit |
|
| 96 | + */ |
|
| 94 | 97 | public function fetchLatest($limit) |
| 95 | 98 | { |
| 96 | 99 | return $this->articleVideosMapper->getLatest($limit); |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | $article = $articleFilter->getValues(); |
| 129 | 129 | $article += [ |
| 130 | - 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']), |
|
| 130 | + 'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]), |
|
| 131 | 131 | 'type' => ArticleType::VIDEO, |
| 132 | 132 | 'article_id' => $id, |
| 133 | 133 | 'article_uuid' => $uuId |
| 134 | 134 | ]; |
| 135 | 135 | |
| 136 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 137 | - unset($article['category_id'], $article['admin_user_id']); |
|
| 136 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 137 | + unset($article[ 'category_id' ], $article[ 'admin_user_id' ]); |
|
| 138 | 138 | |
| 139 | 139 | $videos = $videosFilter->getValues() + [ |
| 140 | 140 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -156,11 +156,11 @@ discard block |
||
| 156 | 156 | throw new FilterException($articleFilter->getMessages() + $videosFilter->getMessages()); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $article = $articleFilter->getValues() + ['article_uuid' => $oldArticle->article_uuid]; |
|
| 160 | - $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid; |
|
| 161 | - $article['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']); |
|
| 162 | - unset($article['category_id']); |
|
| 163 | - unset($article['admin_user_id']); |
|
| 159 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $oldArticle->article_uuid ]; |
|
| 160 | + $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid; |
|
| 161 | + $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]); |
|
| 162 | + unset($article[ 'category_id' ]); |
|
| 163 | + unset($article[ 'admin_user_id' ]); |
|
| 164 | 164 | |
| 165 | 165 | $videos = $videosFilter->getValues() + [ |
| 166 | 166 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
@@ -168,20 +168,20 @@ discard block |
||
| 168 | 168 | ]; |
| 169 | 169 | |
| 170 | 170 | // We don't want to force user to re-upload image on edit |
| 171 | - if (!$videos['featured_img']) { |
|
| 172 | - unset($videos['featured_img']); |
|
| 171 | + if (!$videos[ 'featured_img' ]) { |
|
| 172 | + unset($videos[ 'featured_img' ]); |
|
| 173 | 173 | } else { |
| 174 | 174 | $this->upload->deleteFile($oldArticle->featured_img); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if (!$videos['main_img']) { |
|
| 178 | - unset($videos['main_img']); |
|
| 177 | + if (!$videos[ 'main_img' ]) { |
|
| 178 | + unset($videos[ 'main_img' ]); |
|
| 179 | 179 | } else { |
| 180 | 180 | $this->upload->deleteFile($oldArticle->main_img); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
| 184 | - $this->articleVideosMapper->update($videos, ['article_uuid' => $article['article_uuid']]); |
|
| 183 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 184 | + $this->articleVideosMapper->update($videos, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | public function deleteArticle($id) |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | $this->upload->deleteFile($video->main_img); |
| 196 | 196 | $this->upload->deleteFile($video->featured_img); |
| 197 | - $this->articleVideosMapper->delete(['article_uuid' => $video->article_uuid]); |
|
| 197 | + $this->articleVideosMapper->delete([ 'article_uuid' => $video->article_uuid ]); |
|
| 198 | 198 | $this->delete($video->article_uuid); |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -44,6 +44,9 @@ |
||
| 44 | 44 | return $select; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | + /** |
|
| 48 | + * @param integer $limit |
|
| 49 | + */ |
|
| 47 | 50 | public function getCategoryPostsSelect($categoryId = null, $limit = null) |
| 48 | 51 | { |
| 49 | 52 | $select = $this->getSql()->select() |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function get($id) |
| 35 | 35 | { |
| 36 | - return $this->select(['category_id' => $id])->current(); |
|
| 36 | + return $this->select([ 'category_id' => $id ])->current(); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function getPaginationSelect() |
| 40 | 40 | { |
| 41 | - $select = $this->getSql()->select()->order(['name' => 'asc']); |
|
| 41 | + $select = $this->getSql()->select()->order([ 'name' => 'asc' ]); |
|
| 42 | 42 | |
| 43 | 43 | return $select; |
| 44 | 44 | } |
@@ -46,17 +46,17 @@ discard block |
||
| 46 | 46 | public function getCategoryPostsSelect($categoryId = null, $limit = null) |
| 47 | 47 | { |
| 48 | 48 | $select = $this->getSql()->select() |
| 49 | - ->columns(['category_name' => 'name', 'category_slug' => 'slug']) |
|
| 49 | + ->columns([ 'category_name' => 'name', 'category_slug' => 'slug' ]) |
|
| 50 | 50 | ->join('articles', 'articles.category_uuid = category.category_uuid', |
| 51 | - ['article_id', 'slug', 'admin_user_uuid', 'published_at'] |
|
| 52 | - )->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', ['*'], 'right') |
|
| 51 | + [ 'article_id', 'slug', 'admin_user_uuid', 'published_at' ] |
|
| 52 | + )->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', [ '*' ], 'right') |
|
| 53 | 53 | ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', |
| 54 | - ['admin_user_id', 'first_name', 'last_name', 'face_img'] |
|
| 55 | - )->where(['articles.status' => 1]) |
|
| 56 | - ->order(['published_at' => 'desc']); |
|
| 54 | + [ 'admin_user_id', 'first_name', 'last_name', 'face_img' ] |
|
| 55 | + )->where([ 'articles.status' => 1 ]) |
|
| 56 | + ->order([ 'published_at' => 'desc' ]); |
|
| 57 | 57 | |
| 58 | 58 | if ($categoryId) { |
| 59 | - $select->where(['category_id' => $categoryId]); |
|
| 59 | + $select->where([ 'category_id' => $categoryId ]); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | if ($limit) { |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | $inHomepage = null, |
| 84 | 84 | $inCategoryList = null |
| 85 | 85 | ) { |
| 86 | - $select = $this->getSql()->select()->where(['type' => ArticleType::POST]); |
|
| 86 | + $select = $this->getSql()->select()->where([ 'type' => ArticleType::POST ]); |
|
| 87 | 87 | |
| 88 | 88 | if ($inHomepage !== null) { |
| 89 | - $select->where(['is_in_homepage' => $inHomepage]); |
|
| 89 | + $select->where([ 'is_in_homepage' => $inHomepage ]); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | if ($inCategoryList !== null) { |
| 93 | - $select->where(['is_in_category_list' => $inCategoryList]); |
|
| 93 | + $select->where([ 'is_in_category_list' => $inCategoryList ]); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | if ($limit) { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | return [ |
| 12 | 12 | 'templates' => [ |
| 13 | 13 | 'paths' => [ |
| 14 | - 'article' => [__DIR__ . '/../templates/article'], |
|
| 14 | + 'article' => [ __DIR__ . '/../templates/article' ], |
|
| 15 | 15 | ], |
| 16 | 16 | ], |
| 17 | 17 | |
@@ -51,49 +51,49 @@ discard block |
||
| 51 | 51 | 'name' => 'admin.posts', |
| 52 | 52 | 'path' => '/admin/posts', |
| 53 | 53 | 'middleware' => Controller\PostController::class, |
| 54 | - 'allowed_methods' => ['GET'], |
|
| 54 | + 'allowed_methods' => [ 'GET' ], |
|
| 55 | 55 | ], |
| 56 | 56 | [ |
| 57 | 57 | 'name' => 'admin.posts.action', |
| 58 | 58 | 'path' => '/admin/posts/:action/:id', |
| 59 | 59 | 'middleware' => Controller\PostController::class, |
| 60 | - 'allowed_methods' => ['GET', 'POST'], |
|
| 60 | + 'allowed_methods' => [ 'GET', 'POST' ], |
|
| 61 | 61 | ], |
| 62 | 62 | [ |
| 63 | 63 | 'name' => 'admin.discussions', |
| 64 | 64 | 'path' => '/admin/discussions', |
| 65 | 65 | 'middleware' => Controller\DiscussionController::class, |
| 66 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 66 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 67 | 67 | ], |
| 68 | 68 | [ |
| 69 | 69 | 'name' => 'admin.discussions.action', |
| 70 | 70 | 'path' => '/admin/discussions/:action/:id', |
| 71 | 71 | 'middleware' => Controller\DiscussionController::class, |
| 72 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 72 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 73 | 73 | ], |
| 74 | 74 | [ |
| 75 | 75 | 'name' => 'admin.events', |
| 76 | 76 | 'path' => '/admin/events', |
| 77 | 77 | 'middleware' => Controller\EventController::class, |
| 78 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 78 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 79 | 79 | ], |
| 80 | 80 | [ |
| 81 | 81 | 'name' => 'admin.events.action', |
| 82 | 82 | 'path' => '/admin/events/:action/:id', |
| 83 | 83 | 'middleware' => Controller\EventController::class, |
| 84 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 84 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 85 | 85 | ], |
| 86 | 86 | [ |
| 87 | 87 | 'name' => 'admin.videos', |
| 88 | 88 | 'path' => '/admin/videos', |
| 89 | 89 | 'middleware' => Controller\VideoController::class, |
| 90 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 90 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 91 | 91 | ], |
| 92 | 92 | [ |
| 93 | 93 | 'name' => 'admin.videos.action', |
| 94 | 94 | 'path' => '/admin/videos/:action/:id', |
| 95 | 95 | 'middleware' => Controller\VideoController::class, |
| 96 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 96 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 97 | 97 | ] |
| 98 | 98 | ], |
| 99 | 99 | |