Completed
Push — laravel-5 ( 084924...f66d04 )
by Robert
03:24
created
migrations/2014_01_07_073615_create_tagged_table.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,21 +5,21 @@
 block discarded – undo
5 5
 
6 6
 class CreateTaggedTable extends Migration {
7 7
 
8
-	public function up() {
9
-		Schema::create('tagging_tagged', function(Blueprint $table) {
10
-			$table->increments('id');
11
-			if(config('tagging.primary_keys_type') == 'string') {
12
-				$table->string('taggable_id', 36)->index();
13
-			} else {
14
-				$table->integer('taggable_id')->unsigned()->index();
15
-			}
16
-			$table->string('taggable_type', 125)->index();
17
-			$table->string('tag_name', 125);
18
-			$table->string('tag_slug', 125)->index();
19
-		});
20
-	}
8
+    public function up() {
9
+        Schema::create('tagging_tagged', function(Blueprint $table) {
10
+            $table->increments('id');
11
+            if(config('tagging.primary_keys_type') == 'string') {
12
+                $table->string('taggable_id', 36)->index();
13
+            } else {
14
+                $table->integer('taggable_id')->unsigned()->index();
15
+            }
16
+            $table->string('taggable_type', 125)->index();
17
+            $table->string('tag_name', 125);
18
+            $table->string('tag_slug', 125)->index();
19
+        });
20
+    }
21 21
 
22
-	public function down() {
23
-		Schema::drop('tagging_tagged');
24
-	}
22
+    public function down() {
23
+        Schema::drop('tagging_tagged');
24
+    }
25 25
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 	public function up() {
9 9
 		Schema::create('tagging_tagged', function(Blueprint $table) {
10 10
 			$table->increments('id');
11
-			if(config('tagging.primary_keys_type') == 'string') {
11
+			if (config('tagging.primary_keys_type') == 'string') {
12 12
 				$table->string('taggable_id', 36)->index();
13 13
 			} else {
14 14
 				$table->integer('taggable_id')->unsigned()->index();
Please login to merge, or discard this patch.
migrations/2016_06_29_073615_create_tag_groups_table.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,17 +5,17 @@
 block discarded – undo
5 5
 
6 6
 class CreateTagGroupsTable extends Migration {
7 7
 
8
-	public function up()
9
-	{
10
-		Schema::create('tagging_tag_groups', function(Blueprint $table) {
11
-			$table->increments('id');
12
-			$table->string('slug', 125)->index();
13
-			$table->string('name', 125);
14
-		});
15
-	}
8
+    public function up()
9
+    {
10
+        Schema::create('tagging_tag_groups', function(Blueprint $table) {
11
+            $table->increments('id');
12
+            $table->string('slug', 125)->index();
13
+            $table->string('name', 125);
14
+        });
15
+    }
16 16
 
17
-	public function down()
18
-	{
19
-		Schema::drop('tagging_tag_groups');
20
-	}
17
+    public function down()
18
+    {
19
+        Schema::drop('tagging_tag_groups');
20
+    }
21 21
 }
Please login to merge, or discard this patch.
src/Taggable.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
101 101
         }
102 102
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
      *
131 131
      * @param string|array|null $tagNames (or null to remove all tags)
132 132
      */
133
-    public function untag($tagNames=null)
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->removeTag($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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
185 185
 
186 186
         $className = $query->getModel()->getMorphClass();
187 187
 
188
-        foreach($tagNames as $tagSlug) {
188
+        foreach ($tagNames as $tagSlug) {
189 189
             $tags = Tagged::query()
190 190
                 ->where('tag_slug', TaggingUtility::normalize($tagSlug))
191 191
                 ->where('taggable_type', $className)
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
     {
237 237
         $tagName = trim($tagName);
238 238
 
239
-        if(strlen($tagName) == 0) {
239
+        if (strlen($tagName) == 0) {
240 240
             return;
241 241
         }
242 242
 
243 243
         $tagSlug = TaggingUtility::normalize($tagName);
244 244
 
245 245
         $previousCount = $this->tagged()->where('tag_slug', '=', $tagSlug)->take(1)->count();
246
-        if($previousCount >= 1) { return; }
246
+        if ($previousCount >= 1) { return; }
247 247
 
248 248
         $tagged = new Tagged([
249 249
             'tag_name' => TaggingUtility::displayize($tagName),
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 
270 270
         $tagSlug = TaggingUtility::normalize($tagName);
271 271
 
272
-        if($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
272
+        if ($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
273 273
             TaggingUtility::decrementCount($tagName, $tagSlug, $count);
274 274
         }
275 275
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 
359 359
     private function assembleTagsForScoping($query, $tagNames)
360 360
     {
361
-        if(!is_array($tagNames)) {
361
+        if (!is_array($tagNames)) {
362 362
             $tagNames = func_get_args();
363 363
             array_shift($tagNames);
364 364
         }
Please login to merge, or discard this patch.
src/TaggingUtility.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -155,11 +155,11 @@
 block discarded – undo
155 155
                 'ỹ' => 'y', 'Ỹ' => 'Y', 'ỵ' => 'y', 'Ỵ' => 'Y',
156 156
             
157 157
                 //Kurdish
158
-				'ا' => 'a', 'ب' => 'b', 'ج' => 'c', 'د' => 'd', 'ێ' => 'ee', 'ف' => 'f', 'گ' => 'g',
159
-				'ژ' => 'j', 'ک' => 'k', 'ل' => 'l', 'م' => 'm', 'ن' => 'n', 'ۆ' => 'o',
160
-				'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ت' => 't', 'ڤ' => 'v', 'و' => 'w',
161
-				'خ' => 'x', 'ی' => 'y', 'ز' => 'z', 'ڕ' => 'rr', 'ە' => 'e', 'ح' => 'hh', 'ع' => 'a', 'ش' => 'sh', 'غ' => 'gh', 'ك' => 'k',
162
-				'ڵ' => 'll', 'چ' => 'ch', 'ھ' => 'h', "ئ" => ''
158
+                'ا' => 'a', 'ب' => 'b', 'ج' => 'c', 'د' => 'd', 'ێ' => 'ee', 'ف' => 'f', 'گ' => 'g',
159
+                'ژ' => 'j', 'ک' => 'k', 'ل' => 'l', 'م' => 'm', 'ن' => 'n', 'ۆ' => 'o',
160
+                'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ت' => 't', 'ڤ' => 'v', 'و' => 'w',
161
+                'خ' => 'x', 'ی' => 'y', 'ز' => 'z', 'ڕ' => 'rr', 'ە' => 'e', 'ح' => 'hh', 'ع' => 'a', 'ش' => 'sh', 'غ' => 'gh', 'ك' => 'k',
162
+                'ڵ' => 'll', 'چ' => 'ch', 'ھ' => 'h', "ئ" => ''
163 163
         ];
164 164
 
165 165
         // Make custom replacements
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
      */
19 19
     public static function makeTagArray($tagNames)
20 20
     {
21
-        if(is_array($tagNames) && count($tagNames) == 1) {
21
+        if (is_array($tagNames) && count($tagNames) == 1) {
22 22
             $tagNames = reset($tagNames);
23 23
         }
24 24
 
25
-        if(is_string($tagNames)) {
25
+        if (is_string($tagNames)) {
26 26
             $tagNames = explode(',', $tagNames);
27
-        } elseif(!is_array($tagNames)) {
27
+        } elseif (!is_array($tagNames)) {
28 28
             $tagNames = array(null);
29 29
         }
30 30
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     public static function slug($str)
63 63
     {
64 64
         // Make sure string is in UTF-8 and strip invalid UTF-8 characters
65
-        $str = mb_convert_encoding((string)$str, 'UTF-8');
65
+        $str = mb_convert_encoding((string) $str, 'UTF-8');
66 66
 
67 67
         $options = [
68 68
             'delimiter' => config('taggable.delimiter', '-'),
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
                 'Ă' => 'A', 'ă' => 'a', 'Ș' => 'S', 'ș' => 's', 'Ț' => 'T', 'ț' => 't',
141 141
 
142 142
                 //Vietnamese
143
-                'ả' => 'a', 'Ả' => 'A','ạ' => 'a', 'Ạ' => 'A', 'ắ' => 'a', 'Ắ' => 'A', 'ằ' => 'a', 'Ằ' => 'A',
143
+                'ả' => 'a', 'Ả' => 'A', 'ạ' => 'a', 'Ạ' => 'A', 'ắ' => 'a', 'Ắ' => 'A', 'ằ' => 'a', 'Ằ' => 'A',
144 144
                 'ẳ' => 'a', 'Ẳ' => 'A', 'ẵ' => 'a', 'Ẵ' => 'A', 'ặ' => 'a', 'Ặ' => 'A', 'ẩ' => 'a', 'Ẩ' => 'A',
145 145
                 'Ấ' => 'A', 'ấ' => 'a', 'Ầ' => 'A', 'ầ' => 'a', 'Ơ' => 'O', 'ơ' => 'o', 'Đ' => 'D', 'đ' => 'd',
146 146
                 'ẫ' => 'a', 'Ẫ' => 'A', 'ậ' => 'a', 'Ậ' => 'A', 'ẻ' => 'e', 'Ẻ' => 'E', 'ẽ' => 'e', 'Ẽ' => 'E',
147
-                'ẹ' => 'e', 'Ẹ' => 'E', 'ế' => 'e', 'Ế' => 'E', 'ề' => 'e', 'Ề' => 'E',  'ể' => 'e', 'Ể' => 'E',
147
+                'ẹ' => 'e', 'Ẹ' => 'E', 'ế' => 'e', 'Ế' => 'E', 'ề' => 'e', 'Ề' => 'E', 'ể' => 'e', 'Ể' => 'E',
148 148
                 'ễ' => 'e', 'Ễ' => 'E', 'ệ' => 'e', 'Ệ' => 'E', 'ỉ' => 'i', 'Ỉ' => 'I', 'ĩ' => 'i', 'Ĩ' => 'I',
149 149
                 'ị' => 'i', 'Ị' => 'I', 'ỏ' => 'o', 'Ỏ' => 'O', 'ọ' => 'o', 'Ọ' => 'O', 'ố' => 'o', 'Ố' => 'O',
150 150
                 'ồ' => 'o', 'Ồ' => 'O', 'ổ' => 'o', 'Ổ' => 'O', 'ỗ' => 'o', 'Ỗ' => 'O', 'ộ' => 'o', 'Ộ' => 'O',
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         $str = preg_replace('/[^\p{L}\p{Nd}]+/u', $options['delimiter'], $str);
174 174
 
175 175
         // Remove duplicate delimiters
176
-        $str = preg_replace('/(' . preg_quote($options['delimiter'], '/') . '){2,}/', '$1', $str);
176
+        $str = preg_replace('/('.preg_quote($options['delimiter'], '/').'){2,}/', '$1', $str);
177 177
 
178 178
         // Truncate slug to max. characters
179 179
         $str = mb_substr($str, 0, ($options['limit'] ? $options['limit'] : mb_strlen($str, 'UTF-8')), 'UTF-8');
@@ -194,12 +194,12 @@  discard block
 block discarded – undo
194 194
      */
195 195
     public static function incrementCount($tagString, $tagSlug, $count)
196 196
     {
197
-        if($count <= 0) { return; }
197
+        if ($count <= 0) { return; }
198 198
         $model = static::tagModelString();
199 199
 
200 200
         $tag = $model::where('slug', '=', $tagSlug)->first();
201 201
 
202
-        if(!$tag) {
202
+        if (!$tag) {
203 203
             $tag = new $model;
204 204
             $tag->name = $tagString;
205 205
             $tag->slug = $tagSlug;
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
      */
220 220
     public static function decrementCount($tagString, $tagSlug, $count)
221 221
     {
222
-        if($count <= 0) { return; }
222
+        if ($count <= 0) { return; }
223 223
         $model = static::tagModelString();
224 224
 
225 225
         $tag = $model::where('slug', '=', $tagSlug)->first();
226 226
 
227
-        if($tag) {
227
+        if ($tag) {
228 228
             $tag->count = $tag->count - $count;
229
-            if($tag->count < 0) {
229
+            if ($tag->count < 0) {
230 230
                 $tag->count = 0;
231 231
                 \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.");
232 232
             }
Please login to merge, or discard this patch.
config/tagging.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 return [
4
-	// Datatype for primary keys of your models.
5
-	// used in migrations only
6
-	'primary_keys_type' => 'integer', // 'string' or 'integer'
4
+    // Datatype for primary keys of your models.
5
+    // used in migrations only
6
+    'primary_keys_type' => 'integer', // 'string' or 'integer'
7 7
 		
8
-	// Value of are passed through this before save of tags
9
-	'normalizer' => '\Conner\Tagging\Util::slug',
8
+    // Value of are passed through this before save of tags
9
+    'normalizer' => '\Conner\Tagging\Util::slug',
10 10
 	
11
-	// Display value of tags are passed through (for front end display)
12
-	'displayer' => '\Illuminate\Support\Str::title',
11
+    // Display value of tags are passed through (for front end display)
12
+    'displayer' => '\Illuminate\Support\Str::title',
13 13
 	
14
-	// Database connection for Conner\Taggable\Tag model to use
14
+    // Database connection for Conner\Taggable\Tag model to use
15 15
 // 	'connection' => 'mysql',
16 16
 	
17
-	// When deleting a model, remove all the tags first
18
-	'untag_on_delete' => true,
17
+    // When deleting a model, remove all the tags first
18
+    'untag_on_delete' => true,
19 19
 		
20
-	// Auto-delete unused tags from the 'tags' database table (when they are used zero times)
21
-	'delete_unused_tags' => false,
20
+    // Auto-delete unused tags from the 'tags' database table (when they are used zero times)
21
+    'delete_unused_tags' => false,
22 22
 
23
-	// Model to use to store the tags in the database
24
-	'tag_model'=>'\Conner\Tagging\Model\Tag',
23
+    // Model to use to store the tags in the database
24
+    'tag_model'=>'\Conner\Tagging\Model\Tag',
25 25
 
26
-	// Delimiter used within tags
27
-	'delimiter' => '-',
26
+    // Delimiter used within tags
27
+    'delimiter' => '-',
28 28
 	
29
-	// Model to use for the relation between tags and tagged records
30
-	'tagged_model' => '\Conner\Tagging\Model\Tagged',
29
+    // Model to use for the relation between tags and tagged records
30
+    'tagged_model' => '\Conner\Tagging\Model\Tagged',
31 31
 ];
Please login to merge, or discard this patch.
src/Model/Tag.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function save(array $options = [])
41 41
     {
42
-        if(strlen($this->name) < 1) {
42
+        if (strlen($this->name) < 1) {
43 43
             throw new \RuntimeException('Cannot save a tag with an empty name');
44 44
         }
45 45
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
             return $this;
67 67
         } else {
68
-            throw new \RuntimeException('No Tag Group found: '. $group);
68
+            throw new \RuntimeException('No Tag Group found: '.$group);
69 69
         }
70 70
     }
71 71
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     {
122 122
         $groupSlug = TaggingUtility::normalize($groupName);
123 123
 
124
-        return $query->whereHas('group', function (Builder $query) use ($groupSlug) {
124
+        return $query->whereHas('group', function(Builder $query) use ($groupSlug) {
125 125
             $query->where('slug', $groupSlug);
126 126
         });
127 127
     }
Please login to merge, or discard this patch.
migrations/2014_01_07_073615_create_tags_table.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -5,20 +5,20 @@
 block discarded – undo
5 5
 
6 6
 class CreateTagsTable extends Migration
7 7
 {
8
-	public function up()
9
-	{
10
-		Schema::create('tagging_tags', function(Blueprint $table) {
11
-			$table->increments('id');
12
-			$table->string('slug', 125)->index();
13
-			$table->string('name', 125);
14
-			$table->boolean('suggest')->default(false);
15
-			$table->integer('count')->unsigned()->default(0); // count of how many times this tag was used
8
+    public function up()
9
+    {
10
+        Schema::create('tagging_tags', function(Blueprint $table) {
11
+            $table->increments('id');
12
+            $table->string('slug', 125)->index();
13
+            $table->string('name', 125);
14
+            $table->boolean('suggest')->default(false);
15
+            $table->integer('count')->unsigned()->default(0); // count of how many times this tag was used
16 16
             $table->integer('tag_group_id')->unsigned()->nullable();
17
-		});
18
-	}
17
+        });
18
+    }
19 19
 
20
-	public function down()
21
-	{
22
-		Schema::drop('tagging_tags');
23
-	}
20
+    public function down()
21
+    {
22
+        Schema::drop('tagging_tags');
23
+    }
24 24
 }
Please login to merge, or discard this patch.
migrations/2016_06_29_073615_update_tags_table.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,20 +5,20 @@
 block discarded – undo
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
-		});
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
+        });
13 13
 
14
-	}
14
+    }
15 15
 
16 16
 
17
-	public function down()
18
-	{
17
+    public function down()
18
+    {
19 19
         Schema::disableForeignKeyConstraints();
20
-		Schema::table('tagging_tags', function ($table) {
21
-			$table->dropForeign('tagging_tags_tag_group_id_foreign');
22
-		});
23
-	}
20
+        Schema::table('tagging_tags', function ($table) {
21
+            $table->dropForeign('tagging_tags_tag_group_id_foreign');
22
+        });
23
+    }
24 24
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
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
 		});
13 13
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	public function down()
18 18
 	{
19 19
         Schema::disableForeignKeyConstraints();
20
-		Schema::table('tagging_tags', function ($table) {
20
+		Schema::table('tagging_tags', function($table) {
21 21
 			$table->dropForeign('tagging_tags_tag_group_id_foreign');
22 22
 		});
23 23
 	}
Please login to merge, or discard this patch.