@@ -54,7 +54,7 @@ |
||
54 | 54 | if (!$user) { |
55 | 55 | return $response->withStatus(302)->withHeader( |
56 | 56 | 'Location', |
57 | - $this->router->generateUri('auth', ['action' => 'login']) |
|
57 | + $this->router->generateUri('auth', [ 'action' => 'login' ]) |
|
58 | 58 | ); |
59 | 59 | } |
60 | 60 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | public function get($id) |
33 | 33 | { |
34 | - return $this->select(['admin_user_id' => $id])->current(); |
|
34 | + return $this->select([ 'admin_user_id' => $id ])->current(); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function getByEmail(string $email) |
44 | 44 | { |
45 | - return $this->select(['email' => $email])->current(); |
|
45 | + return $this->select([ 'email' => $email ])->current(); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function updateLogin(string $userId) : int |
55 | 55 | { |
56 | - return $this->update(['last_login' => date('Y-m-d H:i:s')], ['admin_user_id' => $userId]); |
|
56 | + return $this->update([ 'last_login' => date('Y-m-d H:i:s') ], [ 'admin_user_id' => $userId ]); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | public function getPaginationSelect($userId) |
60 | 60 | { |
61 | - $select = $this->getSql()->select()->order(['created_at' => 'desc']); |
|
61 | + $select = $this->getSql()->select()->order([ 'created_at' => 'desc' ]); |
|
62 | 62 | |
63 | 63 | $select->where->notEqualTo('admin_user_id', $userId); |
64 | 64 |
@@ -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 | ]); |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | 'name' => 'password', |
59 | 59 | 'required' => true, |
60 | 60 | 'validators' => [ |
61 | - ['name' => 'NotEmpty'], |
|
62 | - ['name' => 'StringLength', 'options' => ['min' => 7, 'max' => 255]] |
|
61 | + [ 'name' => 'NotEmpty' ], |
|
62 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 7, 'max' => 255 ] ] |
|
63 | 63 | ], |
64 | 64 | ]); |
65 | 65 | |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | 'name' => 'confirm_password', |
68 | 68 | 'required' => true, |
69 | 69 | 'validators' => [ |
70 | - ['name' => 'NotEmpty'], |
|
71 | - ['name' => 'Identical', 'options' => ['token' => 'password']], |
|
70 | + [ 'name' => 'NotEmpty' ], |
|
71 | + [ 'name' => 'Identical', 'options' => [ 'token' => 'password' ] ], |
|
72 | 72 | ], |
73 | 73 | ]); |
74 | 74 | |
75 | 75 | $inputFilter->add([ |
76 | 76 | 'name' => 'status', |
77 | 77 | 'required' => true, |
78 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Digits']] |
|
78 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Digits' ] ] |
|
79 | 79 | ]); |
80 | 80 | |
81 | 81 | $this->inputFilter = $inputFilter; |
@@ -6,18 +6,18 @@ |
||
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 | - ->addForeignKey('admin_user_uuid', 'admin_users', 'admin_user_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
19 | - ->addIndex('type', ['name' => 'type_INDEX']) |
|
20 | - ->addIndex('published_at', ['name' => 'published_at_INDEX']) |
|
17 | + ->addColumn('admin_user_uuid', 'binary', [ 'limit' => 16 ]) |
|
18 | + ->addForeignKey('admin_user_uuid', 'admin_users', 'admin_user_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
19 | + ->addIndex('type', [ 'name' => 'type_INDEX' ]) |
|
20 | + ->addIndex('published_at', [ 'name' => 'published_at_INDEX' ]) |
|
21 | 21 | ->create(); |
22 | 22 | } |
23 | 23 |
@@ -8,22 +8,22 @@ |
||
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('email', 'string', ['limit' => 128]) |
|
17 | - ->addColumn('password', 'char', ['limit' => 60]) |
|
18 | - ->addColumn('status', 'integer', ['default' => 0])// 0 => not active, 1 = active |
|
19 | - ->addColumn('created_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP']) |
|
20 | - ->addColumn('last_login', 'datetime', ['null' => true]) |
|
21 | - ->addIndex(['email'], ['name' => 'email_INDEX']) |
|
16 | + ->addColumn('email', 'string', [ 'limit' => 128 ]) |
|
17 | + ->addColumn('password', 'char', [ 'limit' => 60 ]) |
|
18 | + ->addColumn('status', 'integer', [ 'default' => 0 ])// 0 => not active, 1 = active |
|
19 | + ->addColumn('created_at', 'datetime', [ 'default' => 'CURRENT_TIMESTAMP' ]) |
|
20 | + ->addColumn('last_login', 'datetime', [ 'null' => true ]) |
|
21 | + ->addIndex([ 'email' ], [ 'name' => 'email_INDEX' ]) |
|
22 | 22 | ->create(); |
23 | 23 | |
24 | 24 | $faker = Faker\Factory::create(); |
25 | 25 | $count = rand(100, 150); |
26 | - for($i = 0; $i < $count; $i++){ |
|
26 | + for ($i = 0; $i < $count; $i++) { |
|
27 | 27 | $id = $faker->uuid; |
28 | 28 | $mysqluuid = (new Uuid($id))->toFormat(new Binary()); |
29 | 29 | $data = [ |
@@ -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 |
@@ -10,15 +10,15 @@ discard block |
||
10 | 10 | { |
11 | 11 | public function up() |
12 | 12 | { |
13 | - $this->table('article_videos', ['id' => false]) |
|
14 | - ->addColumn('article_uuid', 'binary', ['limit' => 16]) |
|
13 | + $this->table('article_videos', [ 'id' => false ]) |
|
14 | + ->addColumn('article_uuid', 'binary', [ 'limit' => 16 ]) |
|
15 | 15 | ->addColumn('title', 'text') |
16 | 16 | ->addColumn('body', 'text') |
17 | 17 | ->addColumn('lead', 'text') |
18 | 18 | ->addColumn('embed_code', 'text') |
19 | - ->addColumn('featured_img', 'text', ['null' => true]) |
|
20 | - ->addColumn('main_img', 'text', ['null' => true]) |
|
21 | - ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
19 | + ->addColumn('featured_img', 'text', [ 'null' => true ]) |
|
20 | + ->addColumn('main_img', 'text', [ 'null' => true ]) |
|
21 | + ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
22 | 22 | ->create(); |
23 | 23 | |
24 | 24 | // $this->insertDummyData(); |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | |
32 | 32 | private function insertDummyData() |
33 | 33 | { |
34 | - $ids = []; |
|
34 | + $ids = [ ]; |
|
35 | 35 | $rows = $this->fetchAll('select admin_user_uuid from admin_users;'); |
36 | - foreach($rows as $r){ |
|
37 | - $ids[] = $r['admin_user_uuid']; |
|
36 | + foreach ($rows as $r) { |
|
37 | + $ids[ ] = $r[ 'admin_user_uuid' ]; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | $faker = Faker\Factory::create(); |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | ); |
48 | 48 | |
49 | 49 | // Download N images and set it randomly to posts |
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 | $id = $faker->uuid; |
64 | 64 | $mysqluuid = (new Uuid($id))->toFormat(new Binary()); |
65 | 65 | $title = $faker->sentence(7, 20); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'article_id' => $id, |
70 | 70 | 'slug' => strtolower(trim(preg_replace('~[^\pL\d]+~u', '-', $title), '-')), |
71 | 71 | 'status' => 1, |
72 | - 'admin_user_uuid' => $ids[array_rand($ids)], |
|
72 | + 'admin_user_uuid' => $ids[ array_rand($ids) ], |
|
73 | 73 | 'type' => ArticleType::POST |
74 | 74 | ]; |
75 | 75 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | 'title' => $title, |
79 | 79 | 'body' => $faker->paragraph(15), |
80 | 80 | 'lead' => $faker->paragraph(5), |
81 | - 'main_img' => $mainImg[array_rand($mainImg)], |
|
82 | - 'featured_img' => $featuredImg[array_rand($featuredImg)], |
|
83 | - 'embed_code' => $embedCodes[rand(0, 2)] |
|
81 | + 'main_img' => $mainImg[ array_rand($mainImg) ], |
|
82 | + 'featured_img' => $featuredImg[ array_rand($featuredImg) ], |
|
83 | + 'embed_code' => $embedCodes[ rand(0, 2) ] |
|
84 | 84 | ]; |
85 | 85 | |
86 | 86 | $this->insert('articles', $article); |
@@ -10,19 +10,19 @@ 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 | - ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
25 | + ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
26 | 26 | ->create(); |
27 | 27 | |
28 | 28 | // $this->insertDummyData(); |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | |
36 | 36 | private function insertDummyData() |
37 | 37 | { |
38 | - $ids = []; |
|
38 | + $ids = [ ]; |
|
39 | 39 | $rows = $this->fetchAll('select admin_user_uuid from admin_users;'); |
40 | - foreach($rows as $r){ |
|
41 | - $ids[] = $r['admin_user_uuid']; |
|
40 | + foreach ($rows as $r) { |
|
41 | + $ids[ ] = $r[ 'admin_user_uuid' ]; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $faker = Faker\Factory::create(); |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | $count = rand(25, 300); |
47 | 47 | |
48 | 48 | // Download N images and set it randomly to the events |
49 | - for($i = 0; $i < 5; $i++){ |
|
49 | + for ($i = 0; $i < 5; $i++) { |
|
50 | 50 | $image = $faker->image(); |
51 | 51 | $destination = $upload->getPath(basename($image)); |
52 | 52 | rename($image, $destination); |
53 | - $mainImg[] = substr($destination, strlen('/var/www/unfinished/public')); |
|
53 | + $mainImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); |
|
54 | 54 | |
55 | 55 | $image = $faker->image(); |
56 | 56 | $destination = $upload->getPath(basename($image)); |
57 | 57 | rename($image, $destination); |
58 | - $featuredImg[] = substr($destination, strlen('/var/www/unfinished/public')); |
|
58 | + $featuredImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); |
|
59 | 59 | } |
60 | 60 | |
61 | - for($i = 0; $i < $count; $i++){ |
|
61 | + for ($i = 0; $i < $count; $i++) { |
|
62 | 62 | $start = rand(1, 20); |
63 | 63 | $id = $faker->uuid; |
64 | 64 | $mysqluuid = (new Uuid($id))->toFormat(new Binary()); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'article_id' => $id, |
70 | 70 | 'slug' => strtolower(trim(preg_replace('~[^\pL\d]+~u', '-', $title), '-')), |
71 | 71 | 'status' => 1, |
72 | - 'admin_user_uuid' => $ids[array_rand($ids)], |
|
72 | + 'admin_user_uuid' => $ids[ array_rand($ids) ], |
|
73 | 73 | 'type' => ArticleType::EVENT |
74 | 74 | ]; |
75 | 75 | |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | 'longitude' => $faker->longitude, |
81 | 81 | 'latitude' => $faker->latitude, |
82 | 82 | 'place_name' => $faker->sentence(1), |
83 | - 'main_img' => $mainImg[array_rand($mainImg)], |
|
84 | - 'featured_img' => $featuredImg[array_rand($featuredImg)], |
|
83 | + 'main_img' => $mainImg[ array_rand($mainImg) ], |
|
84 | + 'featured_img' => $featuredImg[ array_rand($featuredImg) ], |
|
85 | 85 | 'start_at' => date("Y-m-d H:i:s", strtotime("+$start day +$start hours")), |
86 | 86 | 'end_at' => date("Y-m-d H:i:s", strtotime("+$start day +" . ($start + rand(1, 5)) . " hours")) |
87 | 87 | ]; |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | - header ( 'Content-type: text/plain'); |
|
3 | + header('Content-type: text/plain'); |
|
4 | 4 | echo " |
5 | 5 | Now see here, you will see the output of the param most |
6 | 6 | interesting to PHP. \$_POST. |