@@ -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 |
@@ -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()')); |
@@ -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 Web\Action; |
6 | 6 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function __invoke(Request $request, Response $response, callable $next = null) |
54 | 54 | { |
55 | 55 | $params = $request->getQueryParams(); |
56 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
56 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
57 | 57 | $futureEvents = $this->eventService->fetchFutureEvents(); |
58 | 58 | $pastEvents = $this->eventService->fetchPastEventsPagination($page, 10); |
59 | 59 |
@@ -19,37 +19,37 @@ discard block |
||
19 | 19 | |
20 | 20 | public function getInputFilter() |
21 | 21 | { |
22 | - if(!$this->inputFilter){ |
|
22 | + if (!$this->inputFilter) { |
|
23 | 23 | $inputFilter = new InputFilter(); |
24 | 24 | |
25 | 25 | $inputFilter->add([ |
26 | 26 | 'name' => 'first_name', |
27 | 27 | 'required' => true, |
28 | - 'filters' => [['name' => 'StringTrim']], |
|
28 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
29 | 29 | 'validators' => [ |
30 | - ['name' => 'NotEmpty'], |
|
31 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 255]] |
|
30 | + [ 'name' => 'NotEmpty' ], |
|
31 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 255 ] ] |
|
32 | 32 | ], |
33 | 33 | ]); |
34 | 34 | |
35 | 35 | $inputFilter->add([ |
36 | 36 | 'name' => 'last_name', |
37 | 37 | 'required' => true, |
38 | - 'filters' => [['name' => 'StringTrim']], |
|
38 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
39 | 39 | 'validators' => [ |
40 | - ['name' => 'NotEmpty'], |
|
41 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 255]] |
|
40 | + [ 'name' => 'NotEmpty' ], |
|
41 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 255 ] ] |
|
42 | 42 | ], |
43 | 43 | ]); |
44 | 44 | |
45 | 45 | $inputFilter->add([ |
46 | 46 | 'name' => 'email', |
47 | 47 | 'required' => true, |
48 | - 'filters' => [['name' => 'StringTrim']], |
|
48 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
49 | 49 | 'validators' => [ |
50 | - ['name' => 'NotEmpty'], |
|
51 | - ['name' => 'EmailAddress'], |
|
52 | - ['name' => 'dbnorecordexists', 'options' => ['adapter' => $this->adapter, 'table' => 'admin_users', 'field' => 'email']], |
|
50 | + [ 'name' => 'NotEmpty' ], |
|
51 | + [ 'name' => 'EmailAddress' ], |
|
52 | + [ 'name' => 'dbnorecordexists', 'options' => [ 'adapter' => $this->adapter, 'table' => 'admin_users', 'field' => 'email' ] ], |
|
53 | 53 | |
54 | 54 | ], |
55 | 55 | ]); |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | $inputFilter->add([ |
58 | 58 | 'name' => 'introduction', |
59 | 59 | 'required' => false, |
60 | - 'filters' => [['name' => 'StringTrim']] |
|
60 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
61 | 61 | ]); |
62 | 62 | |
63 | 63 | $inputFilter->add([ |
64 | 64 | 'name' => 'biography', |
65 | 65 | 'required' => false, |
66 | - 'filters' => [['name' => 'StringTrim']] |
|
66 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
67 | 67 | ]); |
68 | 68 | |
69 | 69 | $inputFilter->add([ |
70 | 70 | 'name' => 'password', |
71 | 71 | 'required' => true, |
72 | 72 | 'validators' => [ |
73 | - ['name' => 'NotEmpty'], |
|
74 | - ['name' => 'StringLength', 'options' => ['min' => 7, 'max' => 255]] |
|
73 | + [ 'name' => 'NotEmpty' ], |
|
74 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 7, 'max' => 255 ] ] |
|
75 | 75 | ], |
76 | 76 | ]); |
77 | 77 | |
@@ -79,15 +79,15 @@ discard block |
||
79 | 79 | 'name' => 'confirm_password', |
80 | 80 | 'required' => true, |
81 | 81 | 'validators' => [ |
82 | - ['name' => 'NotEmpty'], |
|
83 | - ['name' => 'Identical', 'options' => ['token' => 'password']], |
|
82 | + [ 'name' => 'NotEmpty' ], |
|
83 | + [ 'name' => 'Identical', 'options' => [ 'token' => 'password' ] ], |
|
84 | 84 | ], |
85 | 85 | ]); |
86 | 86 | |
87 | 87 | $inputFilter->add([ |
88 | 88 | 'name' => 'status', |
89 | 89 | 'required' => true, |
90 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Digits']] |
|
90 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Digits' ] ] |
|
91 | 91 | ]); |
92 | 92 | |
93 | 93 | $this->inputFilter = $inputFilter; |
@@ -8,21 +8,21 @@ |
||
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 | $faker = Faker\Factory::create(); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Core\Factory\Service; |
5 | 5 | |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function __invoke(ContainerInterface $container): MeetupApiService |
18 | 18 | { |
19 | - $config = $container->get('config')['meetupApi']; |
|
19 | + $config = $container->get('config')[ 'meetupApi' ]; |
|
20 | 20 | |
21 | - return new MeetupApiService($config['key']); |
|
21 | + return new MeetupApiService($config[ 'key' ]); |
|
22 | 22 | } |
23 | 23 | } |
@@ -33,16 +33,16 @@ |
||
33 | 33 | */ |
34 | 34 | public function __invoke($menuItem) |
35 | 35 | { |
36 | - if($menuItem['href']) { |
|
37 | - return strpos($menuItem['href'], 'http') === 0 ? $menuItem['href'] : '/' . $menuItem['href']; |
|
36 | + if ($menuItem[ 'href' ]) { |
|
37 | + return strpos($menuItem[ 'href' ], 'http') === 0 ? $menuItem[ 'href' ] : '/' . $menuItem[ 'href' ]; |
|
38 | 38 | } |
39 | - elseif($menuItem['article_slug']) { |
|
40 | - $params = ['segment_1' => $menuItem['category_slug'], 'segment_2' => $menuItem['article_slug']]; |
|
39 | + elseif ($menuItem[ 'article_slug' ]) { |
|
40 | + $params = [ 'segment_1' => $menuItem[ 'category_slug' ], 'segment_2' => $menuItem[ 'article_slug' ] ]; |
|
41 | 41 | |
42 | 42 | return $this->url->__invoke('post', $params); |
43 | 43 | } |
44 | - elseif($menuItem['category_slug']) { |
|
45 | - return $this->url->__invoke('category', ['category' => $menuItem['category_slug']]); |
|
44 | + elseif ($menuItem[ 'category_slug' ]) { |
|
45 | + return $this->url->__invoke('category', [ 'category' => $menuItem[ 'category_slug' ] ]); |
|
46 | 46 | } |
47 | 47 | else { |
48 | 48 | return '#'; |
@@ -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 Web\Action; |
6 | 6 | |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | public function __invoke(Request $request, Response $response, callable $next = null) |
52 | 52 | { |
53 | 53 | $params = $request->getQueryParams(); |
54 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
54 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
55 | 55 | $urlSlug = $request->getAttribute('category'); |
56 | 56 | $categories = $this->categoryService->allWeb(); |
57 | 57 | $category = $this->categoryService->getCategoryBySlug($urlSlug); |
58 | 58 | |
59 | - if(!$category) { |
|
60 | - $category = (object)[ |
|
59 | + if (!$category) { |
|
60 | + $category = (object) [ |
|
61 | 61 | 'name' => 'Svi članci', |
62 | 62 | 'slug' => 'all' |
63 | 63 | ]; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Core\Mapper; |
5 | 5 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function get($id) |
35 | 35 | { |
36 | - return $this->select(['admin_user_id' => $id])->current(); |
|
36 | + return $this->select([ 'admin_user_id' => $id ])->current(); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function getByEmail(string $email) |
46 | 46 | { |
47 | - return $this->select(['email' => $email])->current(); |
|
47 | + return $this->select([ 'email' => $email ])->current(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function updateLogin(string $userId): int |
57 | 57 | { |
58 | - return $this->update(['last_login' => date('Y-m-d H:i:s')], ['admin_user_id' => $userId]); |
|
58 | + return $this->update([ 'last_login' => date('Y-m-d H:i:s') ], [ 'admin_user_id' => $userId ]); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function getPaginationSelect($userId) |
62 | 62 | { |
63 | - $select = $this->getSql()->select()->order(['created_at' => 'desc']); |
|
63 | + $select = $this->getSql()->select()->order([ 'created_at' => 'desc' ]); |
|
64 | 64 | |
65 | 65 | $select->where->notEqualTo('admin_user_id', $userId); |
66 | 66 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | public function getRandom($limit) |
71 | 71 | { |
72 | 72 | $select = $this->getSql()->select() |
73 | - ->where(['status' => 1]) |
|
73 | + ->where([ 'status' => 1 ]) |
|
74 | 74 | ->order(new Expression('rand()')) |
75 | 75 | ->limit($limit); |
76 | 76 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | |
80 | 80 | public function getUuid($adminUserId) |
81 | 81 | { |
82 | - $user = $this->select(['admin_user_id' => $adminUserId])->current(); |
|
82 | + $user = $this->select([ 'admin_user_id' => $adminUserId ])->current(); |
|
83 | 83 | |
84 | - if(!$user) { |
|
84 | + if (!$user) { |
|
85 | 85 | throw new \Exception('Admin user does not exist!', 400); |
86 | 86 | } |
87 | 87 |