@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | { |
9 | 9 | public function up(): void |
10 | 10 | { |
11 | - Schema::table('temp_tags', function (Blueprint $table) { |
|
11 | + Schema::table('temp_tags', function(Blueprint $table) { |
|
12 | 12 | $table->json('payload')->nullable(); |
13 | 13 | $table->dropColumn('note'); |
14 | 14 | }); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function down(): void |
23 | 23 | { |
24 | - Schema::table('temp_tags', function (Blueprint $table) { |
|
24 | + Schema::table('temp_tags', function(Blueprint $table) { |
|
25 | 25 | $table->dropColumn('payload'); |
26 | 26 | }); |
27 | 27 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up(): void |
15 | 15 | { |
16 | - Schema::create('temp_tags', function (Blueprint $table) { |
|
16 | + Schema::create('temp_tags', function(Blueprint $table) { |
|
17 | 17 | $table->unsignedBigInteger('id', true); |
18 | 18 | $table->string('taggable_type', 25); |
19 | 19 | $table->unsignedBigInteger('taggable_id'); |
@@ -23,43 +23,43 @@ |
||
23 | 23 | { |
24 | 24 | $this->registerConsoleCommands(); |
25 | 25 | |
26 | - Builder::macro('hasActiveTempTags', function ($title) { |
|
26 | + Builder::macro('hasActiveTempTags', function($title) { |
|
27 | 27 | $table = $this->getModel()->getTable(); |
28 | - if (! in_array($table, TempTagServiceProvider::$registeredRelation)) { |
|
28 | + if (!in_array($table, TempTagServiceProvider::$registeredRelation)) { |
|
29 | 29 | TempTagServiceProvider::$registeredRelation[] = $table; |
30 | 30 | Relation::morphMap([ |
31 | 31 | $table => get_class($this->getModel()), |
32 | 32 | ]); |
33 | 33 | } |
34 | 34 | |
35 | - return $this->whereHas('activeTempTags', function ($q) use ($title) { |
|
35 | + return $this->whereHas('activeTempTags', function($q) use ($title) { |
|
36 | 36 | $q->whereIn('title', (array) $title); |
37 | 37 | }); |
38 | 38 | }); |
39 | 39 | |
40 | - Builder::macro('hasExpiredTempTags', function ($title) { |
|
40 | + Builder::macro('hasExpiredTempTags', function($title) { |
|
41 | 41 | $table = $this->getModel()->getTable(); |
42 | - if (! in_array($table, TempTagServiceProvider::$registeredRelation)) { |
|
42 | + if (!in_array($table, TempTagServiceProvider::$registeredRelation)) { |
|
43 | 43 | TempTagServiceProvider::$registeredRelation[] = $table; |
44 | 44 | Relation::morphMap([ |
45 | 45 | $table => get_class($this->getModel()), |
46 | 46 | ]); |
47 | 47 | } |
48 | 48 | |
49 | - return $this->whereHas('expiredTempTags', function ($q) use ($title) { |
|
49 | + return $this->whereHas('expiredTempTags', function($q) use ($title) { |
|
50 | 50 | $q->whereIn('title', (array) $title); |
51 | 51 | }); |
52 | 52 | }); |
53 | 53 | |
54 | - Builder::macro('hasTempTags', function ($title) { |
|
54 | + Builder::macro('hasTempTags', function($title) { |
|
55 | 55 | $table = $this->getModel()->getTable(); |
56 | - if (! in_array($table, TempTagServiceProvider::$registeredRelation)) { |
|
56 | + if (!in_array($table, TempTagServiceProvider::$registeredRelation)) { |
|
57 | 57 | TempTagServiceProvider::$registeredRelation[] = $table; |
58 | 58 | |
59 | - Relation::morphMap([$table => get_class($this->getModel()),]); |
|
59 | + Relation::morphMap([$table => get_class($this->getModel()), ]); |
|
60 | 60 | } |
61 | 61 | |
62 | - return $this->whereHas('tempTags', function ($q) use ($title) { |
|
62 | + return $this->whereHas('tempTags', function($q) use ($title) { |
|
63 | 63 | $q->whereIn('title', (array) $title); |
64 | 64 | }); |
65 | 65 | }); |
@@ -181,7 +181,7 @@ |
||
181 | 181 | $r = \Codino\Models\User::query()->hasActiveTempTags(['banned', 'aaa'])->first(); |
182 | 182 | assert($r->email === '[email protected]'); |
183 | 183 | |
184 | - $r = \Codino\Models\User::query()->hasTempTags(['banned', 'aaa'])->first(); |
|
184 | + $r = \Codino\Models\User::query()->hasTempTags(['banned', 'aaa'])->first(); |
|
185 | 185 | assert($r->email === '[email protected]'); |
186 | 186 | |
187 | 187 | // expire the tag |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | tempTags($user)->getActiveTag('banned'), |
60 | 60 | tempTags($user)->getAllTags()->first()->title, |
61 | 61 | ]; |
62 | - assert($res === [false, false, null, 'banned' ]); |
|
62 | + assert($res === [false, false, null, 'banned']); |
|
63 | 63 | |
64 | 64 | # =================== test deleted tag ===================== |
65 | 65 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | tempTags($user)->getAllTags()->count(), |
147 | 147 | ]; |
148 | 148 | |
149 | - assert($res === ['banned', false, null, 1,]); |
|
149 | + assert($res === ['banned', false, null, 1, ]); |
|
150 | 150 | |
151 | 151 | # ================== make permanent ====================== |
152 | 152 |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $exp = $this->expireDate($carbon); |
70 | 70 | |
71 | 71 | $new_tags = []; |
72 | - foreach ((array)$tag as $tg) { |
|
72 | + foreach ((array) $tag as $tg) { |
|
73 | 73 | $data['title'] = $tg; |
74 | 74 | $new_tags[] = $tagObj = TempTag::query()->updateOrCreate($data, $data + $exp + ['payload' => $payload]); |
75 | 75 | $this->fireEvent($eventName, $tagObj); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | $tags = TempTag::query()->where($forTaggable); |
86 | 86 | |
87 | - $titles && $tags->whereIn('title', (array)$titles); |
|
87 | + $titles && $tags->whereIn('title', (array) $titles); |
|
88 | 88 | $tags = $tags->get(); |
89 | 89 | $this->deleteAll($tags); |
90 | 90 | } |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | |
120 | 120 | private function fireEvent($event, $tag) |
121 | 121 | { |
122 | - ! $event && $event = 'tmp_tagged'; |
|
122 | + !$event && $event = 'tmp_tagged'; |
|
123 | 123 | |
124 | - $event .= ':'.$this->model->getTable().','.$tag->title; |
|
124 | + $event .= ':' . $this->model->getTable() . ',' . $tag->title; |
|
125 | 125 | |
126 | 126 | event($event, [$this->model, $tag]); |
127 | 127 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | private function deleteAll($tags) |
142 | 142 | { |
143 | - $tags->each(function ($tag) { |
|
143 | + $tags->each(function($tag) { |
|
144 | 144 | $tag->delete(); |
145 | 145 | }); |
146 | 146 | } |
@@ -80,7 +80,7 @@ |
||
80 | 80 | */ |
81 | 81 | public function isTemporary(): bool |
82 | 82 | { |
83 | - return ! $this->isPermanent(); |
|
83 | + return !$this->isPermanent(); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | public function scopeWhereTaggable(Builder $query, $taggable): Builder |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | use Imanghafoori\Tags\Services\TagService; |
4 | 4 | |
5 | -if (! function_exists('tempTags')) { |
|
5 | +if (!function_exists('tempTags')) { |
|
6 | 6 | function tempTags($model): TagService |
7 | 7 | { |
8 | 8 | $tagService = new TagService(); |