@@ -4,7 +4,6 @@ |
||
4 | 4 | use MysqlUuid\Formats\Binary; |
5 | 5 | use MysqlUuid\Uuid; |
6 | 6 | use Core\Entity\ArticleType; |
7 | -use MysqlUuid\Formats\PlainString; |
|
8 | 7 | |
9 | 8 | class ArticleDiscussions extends AbstractMigration |
10 | 9 | { |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | { |
11 | 11 | public function up() |
12 | 12 | { |
13 | - $this->table('article_discussions', ['id' => false]) |
|
14 | - ->addColumn('article_uuid', 'binary', ['limit' => 16]) |
|
13 | + $this->table('article_discussions', [ 'id' => false ]) |
|
14 | + ->addColumn('article_uuid', 'binary', [ 'limit' => 16 ]) |
|
15 | 15 | ->addColumn('title', 'text') |
16 | 16 | ->addColumn('body', 'text') |
17 | - ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
17 | + ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
18 | 18 | ->create(); |
19 | 19 | |
20 | 20 | // $this->insertDummyData(); |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | |
28 | 28 | private function insertDummyData() |
29 | 29 | { |
30 | - $ids = []; |
|
30 | + $ids = [ ]; |
|
31 | 31 | $rows = $this->fetchAll('select admin_user_uuid from admin_users;'); |
32 | - foreach($rows as $r){ |
|
33 | - $ids[] = $r['admin_user_uuid']; |
|
32 | + foreach ($rows as $r) { |
|
33 | + $ids[ ] = $r[ 'admin_user_uuid' ]; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | $faker = Faker\Factory::create(); |
37 | 37 | $count = rand(250, 300); |
38 | - for($i = 0; $i < $count; $i++){ |
|
38 | + for ($i = 0; $i < $count; $i++) { |
|
39 | 39 | $id = $faker->uuid; |
40 | 40 | $mysqluuid = (new Uuid($id))->toFormat(new Binary()); |
41 | 41 | $title = $faker->sentence(5, 15); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | 'article_id' => $id, |
46 | 46 | 'slug' => strtolower(trim(preg_replace('~[^\pL\d]+~u', '-', $title), '-')), |
47 | 47 | 'status' => 1, |
48 | - 'admin_user_uuid' => $ids[array_rand($ids)], |
|
48 | + 'admin_user_uuid' => $ids[ array_rand($ids) ], |
|
49 | 49 | 'type' => ArticleType::DISCUSSION |
50 | 50 | ]; |
51 | 51 |
@@ -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. |
@@ -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 | } |
@@ -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() |
@@ -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 Category\Mapper; |
6 | 6 | |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | |
35 | 35 | public function get($id) |
36 | 36 | { |
37 | - return $this->select(['category_id' => $id])->current(); |
|
37 | + return $this->select([ 'category_id' => $id ])->current(); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function getPaginationSelect() |
41 | 41 | { |
42 | - $select = $this->getSql()->select()->order(['name' => 'asc']); |
|
42 | + $select = $this->getSql()->select()->order([ 'name' => 'asc' ]); |
|
43 | 43 | |
44 | 44 | return $select; |
45 | 45 | } |
@@ -47,18 +47,18 @@ discard block |
||
47 | 47 | public function getCategoryPostsSelect($categoryId = null, $limit = null) |
48 | 48 | { |
49 | 49 | $select = $this->getSql()->select() |
50 | - ->columns(['category_name' => 'name', 'category_slug' => 'slug']) |
|
51 | - ->join('articles', 'articles.category_uuid = category.category_uuid', ['article_id', 'slug', 'admin_user_uuid', 'published_at']) |
|
52 | - ->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', ['*'], 'right') |
|
53 | - ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id', 'first_name', 'last_name', 'face_img']) |
|
54 | - ->where(['articles.status' => 1]) |
|
55 | - ->order(['published_at' => 'desc']); |
|
56 | - |
|
57 | - if($categoryId) { |
|
58 | - $select->where(['category_id' => $categoryId]); |
|
50 | + ->columns([ 'category_name' => 'name', 'category_slug' => 'slug' ]) |
|
51 | + ->join('articles', 'articles.category_uuid = category.category_uuid', [ 'article_id', 'slug', 'admin_user_uuid', 'published_at' ]) |
|
52 | + ->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', [ '*' ], 'right') |
|
53 | + ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id', 'first_name', 'last_name', 'face_img' ]) |
|
54 | + ->where([ 'articles.status' => 1 ]) |
|
55 | + ->order([ 'published_at' => 'desc' ]); |
|
56 | + |
|
57 | + if ($categoryId) { |
|
58 | + $select->where([ 'category_id' => $categoryId ]); |
|
59 | 59 | } |
60 | 60 | |
61 | - if($limit) { |
|
61 | + if ($limit) { |
|
62 | 62 | $select->limit($limit); |
63 | 63 | } |
64 | 64 | |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | $select->where->notEqualTo('slug', 'videos'); |
75 | 75 | $select->where->notEqualTo('slug', 'events'); |
76 | 76 | |
77 | - if($limit) { |
|
77 | + if ($limit) { |
|
78 | 78 | $select->limit($limit); |
79 | 79 | } |
80 | 80 | |
81 | - if($order) { |
|
81 | + if ($order) { |
|
82 | 82 | $select->order($order); |
83 | 83 | } else { |
84 | 84 | $select->order(new Expression('rand()')); |
@@ -12,24 +12,24 @@ discard block |
||
12 | 12 | |
13 | 13 | public function getInputFilter() |
14 | 14 | { |
15 | - if(!$this->inputFilter) { |
|
15 | + if (!$this->inputFilter) { |
|
16 | 16 | $inputFilter = new InputFilter(); |
17 | 17 | |
18 | 18 | $inputFilter->add([ |
19 | 19 | 'name' => 'slug', |
20 | 20 | 'required' => true, |
21 | - 'filters' => [['name' => 'StringTrim', 'options' => ['charlist' => '/']]], |
|
21 | + 'filters' => [ [ 'name' => 'StringTrim', 'options' => [ 'charlist' => '/' ] ] ], |
|
22 | 22 | 'validators' => [ |
23 | - ['name' => 'NotEmpty'], |
|
24 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]], |
|
23 | + [ 'name' => 'NotEmpty' ], |
|
24 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ], |
|
25 | 25 | ], |
26 | 26 | ]); |
27 | 27 | |
28 | 28 | $inputFilter->add([ |
29 | 29 | 'name' => 'published_at', |
30 | 30 | 'required' => true, |
31 | - 'filters' => [['name' => 'StringTrim']], |
|
32 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Date', 'options' => ['format' => 'Y-m-d H:i:s']]] |
|
31 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
32 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Date', 'options' => [ 'format' => 'Y-m-d H:i:s' ] ] ] |
|
33 | 33 | ]); |
34 | 34 | |
35 | 35 | $inputFilter->add([ |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | $inputFilter->add([ |
41 | 41 | 'name' => 'status', |
42 | 42 | 'required' => false, |
43 | - 'filters' => [['name' => 'Boolean']], |
|
43 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
44 | 44 | ]); |
45 | 45 | |
46 | 46 | $inputFilter->add([ |
47 | 47 | 'name' => 'is_wysiwyg_editor', |
48 | 48 | 'required' => false, |
49 | - 'filters' => [['name' => 'Boolean']], |
|
49 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
50 | 50 | ]); |
51 | 51 | |
52 | 52 | $this->inputFilter = $inputFilter; |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | |
32 | 32 | public function getCategoryIds($articleId) |
33 | 33 | { |
34 | - $categories = []; |
|
35 | - foreach($this->articleMapper->getCategories($articleId) as $category) { |
|
36 | - $categories[] = $category->category_id; |
|
34 | + $categories = [ ]; |
|
35 | + foreach ($this->articleMapper->getCategories($articleId) as $category) { |
|
36 | + $categories[ ] = $category->category_id; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return $categories; |
@@ -41,6 +41,6 @@ discard block |
||
41 | 41 | |
42 | 42 | public function delete($articleId) |
43 | 43 | { |
44 | - $this->articleMapper->delete(['article_uuid' => $articleId]); |
|
44 | + $this->articleMapper->delete([ 'article_uuid' => $articleId ]); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -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 | } |
@@ -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 | } |