@@ -12,73 +12,73 @@ |
||
| 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' => 'title', |
| 20 | 20 | 'required' => true, |
| 21 | - 'filters' => [['name' => 'StringTrim']], |
|
| 21 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 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' => 'sub_title', |
| 30 | 30 | 'required' => false, |
| 31 | - 'filters' => [['name' => 'StringTrim']] |
|
| 31 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
| 32 | 32 | ]); |
| 33 | 33 | |
| 34 | 34 | $inputFilter->add([ |
| 35 | 35 | 'name' => 'place_name', |
| 36 | 36 | 'required' => true, |
| 37 | - 'filters' => [['name' => 'StringTrim']] |
|
| 37 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
| 38 | 38 | ]); |
| 39 | 39 | |
| 40 | 40 | $inputFilter->add([ |
| 41 | 41 | 'name' => 'event_url', |
| 42 | 42 | 'required' => false, |
| 43 | - 'filters' => [['name' => 'StringTrim']] |
|
| 43 | + 'filters' => [ [ 'name' => 'StringTrim' ] ] |
|
| 44 | 44 | ]); |
| 45 | 45 | |
| 46 | 46 | $inputFilter->add([ |
| 47 | 47 | 'name' => 'body', |
| 48 | 48 | 'required' => true, |
| 49 | - 'filters' => [['name' => 'StringTrim']], |
|
| 49 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 50 | 50 | 'validators' => [ |
| 51 | - ['name' => 'NotEmpty'], |
|
| 52 | - ['name' => 'StringLength', 'options' => ['min' => 2]], |
|
| 51 | + [ 'name' => 'NotEmpty' ], |
|
| 52 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2 ] ], |
|
| 53 | 53 | ], |
| 54 | 54 | ]); |
| 55 | 55 | |
| 56 | 56 | $inputFilter->add([ |
| 57 | 57 | 'name' => 'start_at', |
| 58 | 58 | 'required' => true, |
| 59 | - 'filters' => [['name' => 'StringTrim']], |
|
| 60 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Date', 'options' => ['format' => 'Y-m-d H:i:s']]] |
|
| 59 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 60 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Date', 'options' => [ 'format' => 'Y-m-d H:i:s' ] ] ] |
|
| 61 | 61 | ]); |
| 62 | 62 | |
| 63 | 63 | $inputFilter->add([ |
| 64 | 64 | 'name' => 'end_at', |
| 65 | 65 | 'required' => true, |
| 66 | - 'filters' => [['name' => 'StringTrim']], |
|
| 67 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Date', 'options' => ['format' => 'Y-m-d H:i:s']]] |
|
| 66 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 67 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Date', 'options' => [ 'format' => 'Y-m-d H:i:s' ] ] ] |
|
| 68 | 68 | ]); |
| 69 | 69 | |
| 70 | 70 | $inputFilter->add([ |
| 71 | 71 | 'name' => 'longitude', |
| 72 | 72 | 'required' => true, |
| 73 | - 'filters' => [['name' => 'StringTrim']], |
|
| 74 | - 'validators' => [['name' => 'NotEmpty']], |
|
| 73 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 74 | + 'validators' => [ [ 'name' => 'NotEmpty' ] ], |
|
| 75 | 75 | ]); |
| 76 | 76 | |
| 77 | 77 | $inputFilter->add([ |
| 78 | 78 | 'name' => 'latitude', |
| 79 | 79 | 'required' => true, |
| 80 | - 'filters' => [['name' => 'StringTrim']], |
|
| 81 | - 'validators' => [['name' => 'NotEmpty']], |
|
| 80 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 81 | + 'validators' => [ [ 'name' => 'NotEmpty' ] ], |
|
| 82 | 82 | ]); |
| 83 | 83 | |
| 84 | 84 | $this->inputFilter = $inputFilter; |
@@ -10,20 +10,20 @@ 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 | - ->addColumn('event_url', 'text', ['null' => true]) |
|
| 26 | - ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
| 25 | + ->addColumn('event_url', 'text', [ 'null' => true ]) |
|
| 26 | + ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
| 27 | 27 | ->create(); |
| 28 | 28 | |
| 29 | 29 | // $this->insertDummyData(); |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | private function insertDummyData() |
| 38 | 38 | { |
| 39 | - $ids = []; |
|
| 39 | + $ids = [ ]; |
|
| 40 | 40 | $rows = $this->fetchAll('select admin_user_uuid from admin_users;'); |
| 41 | - foreach($rows as $r){ |
|
| 42 | - $ids[] = $r['admin_user_uuid']; |
|
| 41 | + foreach ($rows as $r) { |
|
| 42 | + $ids[ ] = $r[ 'admin_user_uuid' ]; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $faker = Faker\Factory::create(); |
@@ -47,19 +47,19 @@ discard block |
||
| 47 | 47 | $count = rand(25, 300); |
| 48 | 48 | |
| 49 | 49 | // Download N images and set it randomly to the events |
| 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 | $start = rand(1, 20); |
| 64 | 64 | $id = $faker->uuid; |
| 65 | 65 | $mysqluuid = (new Uuid($id))->toFormat(new Binary()); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | 'article_id' => $id, |
| 71 | 71 | 'slug' => strtolower(trim(preg_replace('~[^\pL\d]+~u', '-', $title), '-')), |
| 72 | 72 | 'status' => 1, |
| 73 | - 'admin_user_uuid' => $ids[array_rand($ids)], |
|
| 73 | + 'admin_user_uuid' => $ids[ array_rand($ids) ], |
|
| 74 | 74 | 'type' => ArticleType::EVENT |
| 75 | 75 | ]; |
| 76 | 76 | |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | 'longitude' => $faker->longitude, |
| 82 | 82 | 'latitude' => $faker->latitude, |
| 83 | 83 | 'place_name' => $faker->sentence(1), |
| 84 | - 'main_img' => $mainImg[array_rand($mainImg)], |
|
| 85 | - 'featured_img' => $featuredImg[array_rand($featuredImg)], |
|
| 84 | + 'main_img' => $mainImg[ array_rand($mainImg) ], |
|
| 85 | + 'featured_img' => $featuredImg[ array_rand($featuredImg) ], |
|
| 86 | 86 | 'start_at' => date("Y-m-d H:i:s", strtotime("+$start day +$start hours")), |
| 87 | 87 | 'end_at' => date("Y-m-d H:i:s", strtotime("+$start day +" . ($start + rand(1, 5)) . " hours")) |
| 88 | 88 | ]; |