@@ -5,21 +5,21 @@ |
||
| 5 | 5 | |
| 6 | 6 | class UpdateTagsTable extends Migration { |
| 7 | 7 | |
| 8 | - public function up() |
|
| 9 | - { |
|
| 10 | - Schema::table('tagging_tags', function ($table) { |
|
| 11 | - $table->foreign('tag_group_id')->references('id')->on('tagging_tag_groups'); |
|
| 12 | - $table->string('locale', 32); |
|
| 13 | - }); |
|
| 8 | + public function up() |
|
| 9 | + { |
|
| 10 | + Schema::table('tagging_tags', function ($table) { |
|
| 11 | + $table->foreign('tag_group_id')->references('id')->on('tagging_tag_groups'); |
|
| 12 | + $table->string('locale', 32); |
|
| 13 | + }); |
|
| 14 | 14 | |
| 15 | - } |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | - public function down() |
|
| 19 | - { |
|
| 18 | + public function down() |
|
| 19 | + { |
|
| 20 | 20 | Schema::disableForeignKeyConstraints(); |
| 21 | - Schema::table('tagging_tags', function ($table) { |
|
| 22 | - $table->dropForeign('tagging_tags_tag_group_id_foreign'); |
|
| 23 | - }); |
|
| 24 | - } |
|
| 21 | + Schema::table('tagging_tags', function ($table) { |
|
| 22 | + $table->dropForeign('tagging_tags_tag_group_id_foreign'); |
|
| 23 | + }); |
|
| 24 | + } |
|
| 25 | 25 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public function up() |
| 9 | 9 | { |
| 10 | - Schema::table('tagging_tags', function ($table) { |
|
| 10 | + Schema::table('tagging_tags', function($table) { |
|
| 11 | 11 | $table->foreign('tag_group_id')->references('id')->on('tagging_tag_groups'); |
| 12 | 12 | $table->string('locale', 32); |
| 13 | 13 | }); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | public function down() |
| 19 | 19 | { |
| 20 | 20 | Schema::disableForeignKeyConstraints(); |
| 21 | - Schema::table('tagging_tags', function ($table) { |
|
| 21 | + Schema::table('tagging_tags', function($table) { |
|
| 22 | 22 | $table->dropForeign('tagging_tags_tag_group_id_foreign'); |
| 23 | 23 | }); |
| 24 | 24 | } |
@@ -162,7 +162,7 @@ |
||
| 162 | 162 | 'ỹ' => 'y', 'Ỹ' => 'Y', 'ỵ' => 'y', 'Ỵ' => 'Y', |
| 163 | 163 | |
| 164 | 164 | //Kurdish |
| 165 | - 'ا' => 'a', 'ب' => 'b', 'ج' => 'c', 'د' => 'd', 'ێ' => 'e', 'ف' => 'f', 'گ' => 'g', 'ژ' => 'j', |
|
| 165 | + 'ا' => 'a', 'ب' => 'b', 'ج' => 'c', 'د' => 'd', 'ێ' => 'e', 'ف' => 'f', 'گ' => 'g', 'ژ' => 'j', |
|
| 166 | 166 | 'ک' => 'k', 'ل' => 'l', 'م' => 'm', 'ن' => 'n', 'ۆ' => 'o', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', |
| 167 | 167 | 'س' => 's', 'ت' => 't', 'ڤ' => 'v','وو' => 'u', 'و' => 'w', 'خ' => 'x', 'ی' => 'y', 'ز' => 'z', |
| 168 | 168 | 'ڕ' => 'rr', 'ە' => 'e', 'ح' => 'hh', 'ع' => '', 'ش' => 'sh', 'غ' => 'gh', 'ك' => 'k', 'ڵ' => 'll', |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public static function makeTagArray($tagNames) |
| 22 | 22 | { |
| 23 | - if(is_array($tagNames) && count($tagNames) == 1) { |
|
| 23 | + if (is_array($tagNames) && count($tagNames) == 1) { |
|
| 24 | 24 | $tagNames = reset($tagNames); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if(is_string($tagNames)) { |
|
| 27 | + if (is_string($tagNames)) { |
|
| 28 | 28 | $tagNames = explode(',', $tagNames); |
| 29 | - } elseif(!is_array($tagNames)) { |
|
| 29 | + } elseif (!is_array($tagNames)) { |
|
| 30 | 30 | $tagNames = array(null); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $normalizer = config('tagging.normalizer'); |
| 49 | 49 | |
| 50 | - if(is_string($normalizer) && Str::contains($normalizer, 'Conner\Tagging\Util')) { |
|
| 50 | + if (is_string($normalizer) && Str::contains($normalizer, 'Conner\Tagging\Util')) { |
|
| 51 | 51 | $normalizer = '\Conner\Tagging\TaggingUtility::slug'; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public static function slug($str) |
| 70 | 70 | { |
| 71 | 71 | // Make sure string is in UTF-8 and strip invalid UTF-8 characters |
| 72 | - $str = mb_convert_encoding((string)$str, 'UTF-8'); |
|
| 72 | + $str = mb_convert_encoding((string) $str, 'UTF-8'); |
|
| 73 | 73 | |
| 74 | 74 | $options = [ |
| 75 | 75 | 'delimiter' => config('taggable.delimiter', '-'), |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | 'Ă' => 'A', 'ă' => 'a', 'Ș' => 'S', 'ș' => 's', 'Ț' => 'T', 'ț' => 't', |
| 148 | 148 | |
| 149 | 149 | //Vietnamese |
| 150 | - 'ả' => 'a', 'Ả' => 'A','ạ' => 'a', 'Ạ' => 'A', 'ắ' => 'a', 'Ắ' => 'A', 'ằ' => 'a', 'Ằ' => 'A', |
|
| 150 | + 'ả' => 'a', 'Ả' => 'A', 'ạ' => 'a', 'Ạ' => 'A', 'ắ' => 'a', 'Ắ' => 'A', 'ằ' => 'a', 'Ằ' => 'A', |
|
| 151 | 151 | 'ẳ' => 'a', 'Ẳ' => 'A', 'ẵ' => 'a', 'Ẵ' => 'A', 'ặ' => 'a', 'Ặ' => 'A', 'ẩ' => 'a', 'Ẩ' => 'A', |
| 152 | 152 | 'Ấ' => 'A', 'ấ' => 'a', 'Ầ' => 'A', 'ầ' => 'a', 'Ơ' => 'O', 'ơ' => 'o', 'Đ' => 'D', 'đ' => 'd', |
| 153 | 153 | 'ẫ' => 'a', 'Ẫ' => 'A', 'ậ' => 'a', 'Ậ' => 'A', 'ẻ' => 'e', 'Ẻ' => 'E', 'ẽ' => 'e', 'Ẽ' => 'E', |
| 154 | - 'ẹ' => 'e', 'Ẹ' => 'E', 'ế' => 'e', 'Ế' => 'E', 'ề' => 'e', 'Ề' => 'E', 'ể' => 'e', 'Ể' => 'E', |
|
| 154 | + 'ẹ' => 'e', 'Ẹ' => 'E', 'ế' => 'e', 'Ế' => 'E', 'ề' => 'e', 'Ề' => 'E', 'ể' => 'e', 'Ể' => 'E', |
|
| 155 | 155 | 'ễ' => 'e', 'Ễ' => 'E', 'ệ' => 'e', 'Ệ' => 'E', 'ỉ' => 'i', 'Ỉ' => 'I', 'ĩ' => 'i', 'Ĩ' => 'I', |
| 156 | 156 | 'ị' => 'i', 'Ị' => 'I', 'ỏ' => 'o', 'Ỏ' => 'O', 'ọ' => 'o', 'Ọ' => 'O', 'ố' => 'o', 'Ố' => 'O', |
| 157 | 157 | 'ồ' => 'o', 'Ồ' => 'O', 'ổ' => 'o', 'Ổ' => 'O', 'ỗ' => 'o', 'Ỗ' => 'O', 'ộ' => 'o', 'Ộ' => 'O', |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | //Kurdish |
| 165 | 165 | 'ا' => 'a', 'ب' => 'b', 'ج' => 'c', 'د' => 'd', 'ێ' => 'e', 'ف' => 'f', 'گ' => 'g', 'ژ' => 'j', |
| 166 | 166 | 'ک' => 'k', 'ل' => 'l', 'م' => 'm', 'ن' => 'n', 'ۆ' => 'o', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', |
| 167 | - 'س' => 's', 'ت' => 't', 'ڤ' => 'v','وو' => 'u', 'و' => 'w', 'خ' => 'x', 'ی' => 'y', 'ز' => 'z', |
|
| 167 | + 'س' => 's', 'ت' => 't', 'ڤ' => 'v', 'وو' => 'u', 'و' => 'w', 'خ' => 'x', 'ی' => 'y', 'ز' => 'z', |
|
| 168 | 168 | 'ڕ' => 'rr', 'ە' => 'e', 'ح' => 'hh', 'ع' => '', 'ش' => 'sh', 'غ' => 'gh', 'ك' => 'k', 'ڵ' => 'll', |
| 169 | 169 | 'چ' => 'ch', 'ھ' => 'h', "ئ" => '', 'ه' => 'e', 'ه' => 'h', 'ص' => 's', 'ي' => 'y', 'ة' => 'e', |
| 170 | 170 | 'ط' => 't', 'ذ' => 'z', 'ؤ' => 'u', 'ظ' => 'dh', 'ض' => 'dh', 'ث' => 's', 'أ' => 'a', 'إ' => 'i', |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $str = preg_replace('/[^\p{L}\p{Nd}]+/u', $options['delimiter'], $str); |
| 183 | 183 | |
| 184 | 184 | // Remove duplicate delimiters |
| 185 | - $str = preg_replace('/(' . preg_quote($options['delimiter'], '/') . '){2,}/', '$1', $str); |
|
| 185 | + $str = preg_replace('/('.preg_quote($options['delimiter'], '/').'){2,}/', '$1', $str); |
|
| 186 | 186 | |
| 187 | 187 | // Truncate slug to max. characters |
| 188 | 188 | $str = mb_substr($str, 0, ($options['limit'] ? $options['limit'] : mb_strlen($str, 'UTF-8')), 'UTF-8'); |
@@ -203,12 +203,12 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public static function incrementCount($tagString, $tagSlug, $count, $locale) |
| 205 | 205 | { |
| 206 | - if($count <= 0) { return; } |
|
| 206 | + if ($count <= 0) { return; } |
|
| 207 | 207 | $model = static::tagModelString(); |
| 208 | 208 | |
| 209 | 209 | $tag = $model::where('slug', '=', $tagSlug)->first(); |
| 210 | 210 | |
| 211 | - if(!$tag) { |
|
| 211 | + if (!$tag) { |
|
| 212 | 212 | $tag = new $model; |
| 213 | 213 | $tag->name = $tagString; |
| 214 | 214 | $tag->slug = $tagSlug; |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public static function decrementCount($tagString, $tagSlug, $count) |
| 231 | 231 | { |
| 232 | - if($count <= 0) { return; } |
|
| 232 | + if ($count <= 0) { return; } |
|
| 233 | 233 | $model = static::tagModelString(); |
| 234 | 234 | |
| 235 | 235 | $tag = $model::where('slug', '=', $tagSlug)->first(); |
| 236 | 236 | |
| 237 | - if($tag) { |
|
| 237 | + if ($tag) { |
|
| 238 | 238 | $tag->count = $tag->count - $count; |
| 239 | - if($tag->count < 0) { |
|
| 239 | + if ($tag->count < 0) { |
|
| 240 | 240 | $tag->count = 0; |
| 241 | 241 | \Log::warning("The '.$model.' count for `$tag->name` was a negative number. This probably means your data got corrupted. Please assess your code and report an issue if you find one."); |
| 242 | 242 | } |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public static function bootTaggable() |
| 45 | 45 | { |
| 46 | - if(static::untagOnDelete()) { |
|
| 46 | + if (static::untagOnDelete()) { |
|
| 47 | 47 | static::deleting(function($model) { |
| 48 | 48 | $model->untag(); |
| 49 | 49 | }); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - static::saved(function ($model) { |
|
| 52 | + static::saved(function($model) { |
|
| 53 | 53 | $model->autoTagPostSave(); |
| 54 | 54 | }); |
| 55 | 55 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function getTagsAttribute() |
| 76 | 76 | { |
| 77 | - return $this->tagged->map(function(Tagged $item){ |
|
| 77 | + return $this->tagged->map(function(Tagged $item) { |
|
| 78 | 78 | return $item->tag; |
| 79 | 79 | }); |
| 80 | 80 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $tagNames = TaggingUtility::makeTagArray($tagNames); |
| 98 | 98 | |
| 99 | - foreach($tagNames as $tagName) { |
|
| 99 | + foreach ($tagNames as $tagName) { |
|
| 100 | 100 | $this->addTag($tagName, $locale); |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function tagNames(): array |
| 110 | 110 | { |
| 111 | - return $this->tagged->map(function($item){ |
|
| 111 | + return $this->tagged->map(function($item) { |
|
| 112 | 112 | return $item->tag_name; |
| 113 | 113 | })->toArray(); |
| 114 | 114 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function tagSlugs(): array |
| 122 | 122 | { |
| 123 | - return $this->tagged->map(function($item){ |
|
| 123 | + return $this->tagged->map(function($item) { |
|
| 124 | 124 | return $item->tag_slug; |
| 125 | 125 | })->toArray(); |
| 126 | 126 | } |
@@ -132,17 +132,17 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function untag($tagNames = null) |
| 134 | 134 | { |
| 135 | - if(is_null($tagNames)) { |
|
| 135 | + if (is_null($tagNames)) { |
|
| 136 | 136 | $tagNames = $this->tagNames(); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $tagNames = TaggingUtility::makeTagArray($tagNames); |
| 140 | 140 | |
| 141 | - foreach($tagNames as $tagName) { |
|
| 141 | + foreach ($tagNames as $tagName) { |
|
| 142 | 142 | $this->removeSingleTag($tagName); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if(static::shouldDeleteUnused()) { |
|
| 145 | + if (static::shouldDeleteUnused()) { |
|
| 146 | 146 | TaggingUtility::deleteUnusedTags(); |
| 147 | 147 | } |
| 148 | 148 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | $this->untag($deletions); |
| 164 | 164 | |
| 165 | - foreach($additions as $tagName) { |
|
| 165 | + foreach ($additions as $tagName) { |
|
| 166 | 166 | $this->addTag($tagName); |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function scopeWithAllTags(Builder $query, $tagNames): Builder |
| 178 | 178 | { |
| 179 | - if(!is_array($tagNames)) { |
|
| 179 | + if (!is_array($tagNames)) { |
|
| 180 | 180 | $tagNames = func_get_args(); |
| 181 | 181 | array_shift($tagNames); |
| 182 | 182 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | $className = $query->getModel()->getMorphClass(); |
| 187 | 187 | |
| 188 | - foreach($tagNames as $tagSlug) { |
|
| 188 | + foreach ($tagNames as $tagSlug) { |
|
| 189 | 189 | |
| 190 | 190 | $model = TaggingUtility::taggedModelString(); |
| 191 | 191 | |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | { |
| 240 | 240 | $tagName = trim($tagName); |
| 241 | 241 | |
| 242 | - if(strlen($tagName) == 0) { |
|
| 242 | + if (strlen($tagName) == 0) { |
|
| 243 | 243 | return; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $tagSlug = TaggingUtility::normalize($tagName); |
| 247 | 247 | |
| 248 | 248 | $previousCount = $this->tagged()->where('tag_slug', '=', $tagSlug)->take(1)->count(); |
| 249 | - if($previousCount >= 1) { return; } |
|
| 249 | + if ($previousCount >= 1) { return; } |
|
| 250 | 250 | |
| 251 | 251 | $model = TaggingUtility::taggedModelString(); |
| 252 | 252 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | $tagSlug = TaggingUtility::normalize($tagName); |
| 277 | 277 | |
| 278 | - if($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) { |
|
| 278 | + if ($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) { |
|
| 279 | 279 | TaggingUtility::decrementCount($tagName, $tagSlug, $count); |
| 280 | 280 | } |
| 281 | 281 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | private function assembleTagsForScoping($query, $tagNames) |
| 371 | 371 | { |
| 372 | - if(!is_array($tagNames)) { |
|
| 372 | + if (!is_array($tagNames)) { |
|
| 373 | 373 | $tagNames = func_get_args(); |
| 374 | 374 | array_shift($tagNames); |
| 375 | 375 | } |