@@ -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; |
@@ -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 |
@@ -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 | } |
@@ -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 | ]; |
@@ -6,21 +6,21 @@ |
||
| 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 | - ->addColumn('is_wysiwyg_editor', 'boolean', ['default' => false]) |
|
| 19 | - ->addColumn('category_uuid', 'binary', ['limit' => 16]) |
|
| 20 | - ->addForeignKey('category_uuid', 'category', 'category_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
| 21 | - ->addForeignKey('admin_user_uuid', 'admin_users', 'admin_user_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
| 22 | - ->addIndex('type', ['name' => 'type_INDEX']) |
|
| 23 | - ->addIndex('published_at', ['name' => 'published_at_INDEX']) |
|
| 17 | + ->addColumn('admin_user_uuid', 'binary', [ 'limit' => 16 ]) |
|
| 18 | + ->addColumn('is_wysiwyg_editor', 'boolean', [ 'default' => false ]) |
|
| 19 | + ->addColumn('category_uuid', 'binary', [ 'limit' => 16 ]) |
|
| 20 | + ->addForeignKey('category_uuid', 'category', 'category_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
| 21 | + ->addForeignKey('admin_user_uuid', 'admin_users', 'admin_user_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
| 22 | + ->addIndex('type', [ 'name' => 'type_INDEX' ]) |
|
| 23 | + ->addIndex('published_at', [ 'name' => 'published_at_INDEX' ]) |
|
| 24 | 24 | ->create(); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -10,16 +10,16 @@ discard block |
||
| 10 | 10 | { |
| 11 | 11 | public function up() |
| 12 | 12 | { |
| 13 | - $this->table('article_posts', ['id' => false]) |
|
| 14 | - ->addColumn('article_uuid', 'binary', ['limit' => 16]) |
|
| 13 | + $this->table('article_posts', [ '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 | - ->addColumn('featured_img', 'text', ['null' => true]) |
|
| 19 | - ->addColumn('main_img', 'text', ['null' => true]) |
|
| 20 | - ->addColumn('has_layout', 'boolean', ['default' => true]) |
|
| 21 | - ->addColumn('is_homepage', 'boolean', ['default' => false]) |
|
| 22 | - ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
| 18 | + ->addColumn('featured_img', 'text', [ 'null' => true ]) |
|
| 19 | + ->addColumn('main_img', 'text', [ 'null' => true ]) |
|
| 20 | + ->addColumn('has_layout', 'boolean', [ 'default' => true ]) |
|
| 21 | + ->addColumn('is_homepage', 'boolean', [ 'default' => false ]) |
|
| 22 | + ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
| 23 | 23 | ->create(); |
| 24 | 24 | |
| 25 | 25 | // $this->insertDummyData(); |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | private function insertDummyData() |
| 34 | 34 | { |
| 35 | - $ids = []; |
|
| 35 | + $ids = [ ]; |
|
| 36 | 36 | $rows = $this->fetchAll('select admin_user_uuid from admin_users;'); |
| 37 | - foreach($rows as $r) { |
|
| 38 | - $ids[] = $r['admin_user_uuid']; |
|
| 37 | + foreach ($rows as $r) { |
|
| 38 | + $ids[ ] = $r[ 'admin_user_uuid' ]; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $faker = Faker\Factory::create(); |
@@ -43,19 +43,19 @@ discard block |
||
| 43 | 43 | $count = rand(25, 300); |
| 44 | 44 | |
| 45 | 45 | // Download N images and set it randomly to posts |
| 46 | - for($i = 0; $i < 5; $i++) { |
|
| 46 | + for ($i = 0; $i < 5; $i++) { |
|
| 47 | 47 | $image = $faker->image(); |
| 48 | 48 | $destination = $upload->getPath(basename($image)); |
| 49 | 49 | rename($image, $destination); |
| 50 | - $mainImg[] = substr($destination, strlen('/var/www/unfinished/public')); |
|
| 50 | + $mainImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); |
|
| 51 | 51 | |
| 52 | 52 | $image = $faker->image(); |
| 53 | 53 | $destination = $upload->getPath(basename($image)); |
| 54 | 54 | rename($image, $destination); |
| 55 | - $featuredImg[] = substr($destination, strlen('/var/www/unfinished/public')); |
|
| 55 | + $featuredImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - for($i = 0; $i < $count; $i++) { |
|
| 58 | + for ($i = 0; $i < $count; $i++) { |
|
| 59 | 59 | $id = $faker->uuid; |
| 60 | 60 | $mysqluuid = (new Uuid($id))->toFormat(new Binary()); |
| 61 | 61 | $title = $faker->sentence(7, 20); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | 'article_id' => $id, |
| 66 | 66 | 'slug' => strtolower(trim(preg_replace('~[^\pL\d]+~u', '-', $title), '-')), |
| 67 | 67 | 'status' => 1, |
| 68 | - 'admin_user_uuid' => $ids[array_rand($ids)], |
|
| 68 | + 'admin_user_uuid' => $ids[ array_rand($ids) ], |
|
| 69 | 69 | 'type' => ArticleType::POST |
| 70 | 70 | ]; |
| 71 | 71 | |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | 'title' => $title, |
| 75 | 75 | 'body' => $faker->paragraph(15), |
| 76 | 76 | 'lead' => $faker->paragraph(5), |
| 77 | - 'main_img' => $mainImg[array_rand($mainImg)], |
|
| 78 | - 'featured_img' => $featuredImg[array_rand($featuredImg)] |
|
| 77 | + 'main_img' => $mainImg[ array_rand($mainImg) ], |
|
| 78 | + 'featured_img' => $featuredImg[ array_rand($featuredImg) ] |
|
| 79 | 79 | ]; |
| 80 | 80 | |
| 81 | 81 | $this->insert('articles', $article); |
@@ -10,16 +10,16 @@ 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 | - ->addColumn('sub_title', 'text', ['null' => true]) |
|
| 16 | + ->addColumn('sub_title', 'text', [ 'null' => true ]) |
|
| 17 | 17 | ->addColumn('body', 'text') |
| 18 | 18 | ->addColumn('lead', 'text') |
| 19 | 19 | ->addColumn('video_url', 'text') |
| 20 | - ->addColumn('featured_img', 'text', ['null' => true]) |
|
| 21 | - ->addColumn('main_img', 'text', ['null' => true]) |
|
| 22 | - ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
| 20 | + ->addColumn('featured_img', 'text', [ 'null' => true ]) |
|
| 21 | + ->addColumn('main_img', 'text', [ 'null' => true ]) |
|
| 22 | + ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
| 23 | 23 | ->create(); |
| 24 | 24 | |
| 25 | 25 | // $this->insertDummyData(); |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | private function insertDummyData() |
| 34 | 34 | { |
| 35 | - $ids = []; |
|
| 35 | + $ids = [ ]; |
|
| 36 | 36 | $rows = $this->fetchAll('select admin_user_uuid from admin_users;'); |
| 37 | - foreach($rows as $r) { |
|
| 38 | - $ids[] = $r['admin_user_uuid']; |
|
| 37 | + foreach ($rows as $r) { |
|
| 38 | + $ids[ ] = $r[ 'admin_user_uuid' ]; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $faker = Faker\Factory::create(); |
@@ -48,19 +48,19 @@ discard block |
||
| 48 | 48 | ]; |
| 49 | 49 | |
| 50 | 50 | // Download N images and set it randomly to posts |
| 51 | - for($i = 0; $i < 5; $i++) { |
|
| 51 | + for ($i = 0; $i < 5; $i++) { |
|
| 52 | 52 | $image = $faker->image(); |
| 53 | 53 | $destination = $upload->getPath(basename($image)); |
| 54 | 54 | rename($image, $destination); |
| 55 | - $mainImg[] = substr($destination, strlen('/var/www/unfinished/public')); |
|
| 55 | + $mainImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); |
|
| 56 | 56 | |
| 57 | 57 | $image = $faker->image(); |
| 58 | 58 | $destination = $upload->getPath(basename($image)); |
| 59 | 59 | rename($image, $destination); |
| 60 | - $featuredImg[] = substr($destination, strlen('/var/www/unfinished/public')); |
|
| 60 | + $featuredImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - for($i = 0; $i < $count; $i++) { |
|
| 63 | + for ($i = 0; $i < $count; $i++) { |
|
| 64 | 64 | $id = $faker->uuid; |
| 65 | 65 | $mysqluuid = (new Uuid($id))->toFormat(new Binary()); |
| 66 | 66 | $title = $faker->sentence(7, 20); |
@@ -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::POST |
| 75 | 75 | ]; |
| 76 | 76 | |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | 'title' => $title, |
| 80 | 80 | 'body' => $faker->paragraph(15), |
| 81 | 81 | 'lead' => $faker->paragraph(5), |
| 82 | - 'main_img' => $mainImg[array_rand($mainImg)], |
|
| 83 | - 'featured_img' => $featuredImg[array_rand($featuredImg)], |
|
| 84 | - 'video_url' => $embedCodes[rand(0, 2)] |
|
| 82 | + 'main_img' => $mainImg[ array_rand($mainImg) ], |
|
| 83 | + 'featured_img' => $featuredImg[ array_rand($featuredImg) ], |
|
| 84 | + 'video_url' => $embedCodes[ rand(0, 2) ] |
|
| 85 | 85 | ]; |
| 86 | 86 | |
| 87 | 87 | $this->insert('articles', $article); |
@@ -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 | |