Passed
Push — master ( f22075...1dfec9 )
by Dennis
04:02
created
src/DynamicUnitServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@
 block discarded – undo
28 28
     protected function bindMacroService(): void
29 29
     {
30 30
         if (class_exists(SimpleService::class)) {
31
-            SimpleService::macro('queryAttribute', function (SimpleService $service, array $parameters) {
31
+            SimpleService::macro('queryAttribute', function(SimpleService $service, array $parameters) {
32 32
                 $attributeService = new DynamicAttributeService;
33
-                return $attributeService->queryAttribute($service,$parameters);
33
+                return $attributeService->queryAttribute($service, $parameters);
34 34
             });
35 35
         }
36 36
     }
Please login to merge, or discard this patch.
src/Packages/DynamicUnit.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
     private function convertUnit(Collection $collection)
20 20
     {
21
-        return $collection->map(function (DynamicUnitModel $item) {
21
+        return $collection->map(function(DynamicUnitModel $item) {
22 22
             return new DynamicModel($item->id, $item->name, $item->code, $item->items->map(fn(DynamicAttribute $dynamicAttribute) => new AttributeModel($dynamicAttribute->id, $dynamicAttribute->name, $dynamicAttribute->code, $dynamicAttribute->thumbnail)));
23 23
         });
24 24
     }
Please login to merge, or discard this patch.
src/Packages/DynamicModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 class DynamicModel implements \JsonSerializable
7 7
 {
8 8
 
9
-    public function __construct(public int $id, public string $name, public string $value, public null|Collection $items)
9
+    public function __construct(public int $id, public string $name, public string $value, public null | Collection $items)
10 10
     {
11 11
     }
12 12
 
Please login to merge, or discard this patch.
src/Services/DynamicAttributeService.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@
 block discarded – undo
20 20
      */
21 21
     public function queryAttribute(SimpleService $service, array $parameters): SimpleService
22 22
     {
23
-        $service->setQuery(function ($query) use ($parameters) {
24
-            $query->whereHas('customsAttributes', function ($q) use ($parameters) {
25
-                $q->whereIn('dynamic_attribute_id', function ($subQuery) use ($parameters) {
23
+        $service->setQuery(function($query) use ($parameters) {
24
+            $query->whereHas('customsAttributes', function($q) use ($parameters) {
25
+                $q->whereIn('dynamic_attribute_id', function($subQuery) use ($parameters) {
26 26
                     $subQuery->select('id')
27 27
                         ->from('dynamic_attributes')
28 28
                         ->whereIn('code', $parameters);
Please login to merge, or discard this patch.
src/Traits/DynamicAttributeTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
     public static function bootDynamicAttributeTrait()
29 29
     {
30
-        static::deleting(function ($model) {
30
+        static::deleting(function($model) {
31 31
             $model->customsAttributes->each(fn(CustomAttribute $customsAttribute) => $customsAttribute->delete());
32 32
         });
33 33
     }
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function scopeWithAttributeCodes($query, array $codes)
51 51
     {
52
-        return $query->whereHas('customsAttributes', function ($q) use ($codes) {
53
-            $q->whereIn('dynamic_attribute_id', function ($subQuery) use ($codes) {
52
+        return $query->whereHas('customsAttributes', function($q) use ($codes) {
53
+            $q->whereIn('dynamic_attribute_id', function($subQuery) use ($codes) {
54 54
                 $subQuery->select('id')
55 55
                     ->from('dynamic_attributes')
56 56
                     ->whereIn('code', $codes);
Please login to merge, or discard this patch.
src/Models/DynamicAttribute.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  */
26 26
 class DynamicAttribute extends Model implements HasMedia
27 27
 {
28
-    use MediaAttributeTrait,HasFactory;
28
+    use MediaAttributeTrait, HasFactory;
29 29
 
30 30
     const MEDIA_FILE = 'file';
31 31
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function customsAttributes()
70 70
     {
71
-        return $this->morphMany(CustomAttribute::class,'model');
71
+        return $this->morphMany(CustomAttribute::class, 'model');
72 72
     }
73 73
 
74 74
     public function getThumbnailAttribute()
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,8 +73,9 @@
 block discarded – undo
73 73
 
74 74
     public function getThumbnailAttribute()
75 75
     {
76
-        if (!$media = $this->getFirstMedia(self::MEDIA_FILE))
77
-            return [];
76
+        if (!$media = $this->getFirstMedia(self::MEDIA_FILE)) {
77
+                    return [];
78
+        }
78 79
         return [
79 80
             'name' => $media->file_name,
80 81
             'url' => $media->original_url,
Please login to merge, or discard this patch.
database/migrations/2024_07_20_153610_create_dynamic_attributes_table.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public function up(): void
13 13
     {
14
-        Schema::create('dynamic_attributes', function (Blueprint $table) {
14
+        Schema::create('dynamic_attributes', function(Blueprint $table) {
15 15
             $table->id();
16 16
             $table->foreignId("dynamic_unit_id")->constrained("dynamic_units")->index()->comment('属性ID');
17 17
             $table->string("name")->comment("名称");
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
             $table->timestamps();
20 20
             $table->comment('动态单元属性表');
21 21
         });
22
-        Schema::create('customs_attributes', function (Blueprint $table) {
22
+        Schema::create('customs_attributes', function(Blueprint $table) {
23 23
             $table->integer('dynamic_attribute_id')->comment("属性ID");
24 24
             $table->string("model_id")->comment("关联ID");
25 25
             $table->string("model_type")->nullable()->comment("关联类");
Please login to merge, or discard this patch.
database/migrations/2024_07_20_153536_create_dynamic_units_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
      */
12 12
     public function up(): void
13 13
     {
14
-        Schema::create('dynamic_units', function (Blueprint $table) {
14
+        Schema::create('dynamic_units', function(Blueprint $table) {
15 15
             $table->id();
16 16
             $table->string("name")->comment("属性名称");
17 17
             $table->string("code")->index()->nullable()->comment("属性标识");
Please login to merge, or discard this patch.
src/Packages/DynamicQuery.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     }
131 131
 
132 132
 
133
-    private static function convertSql(array $data): array|bool
133
+    private static function convertSql(array $data): array | bool
134 134
     {
135 135
         $sql = [];
136 136
         $map = array_merge([
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         return [$sql, $map['file'], $map['id']];
149 149
     }
150 150
 
151
-    private static function pullFile(array $data): null|UploadedFile
151
+    private static function pullFile(array $data): null | UploadedFile
152 152
     {
153 153
         if (array_key_exists('file', $data) && $data['file']) {
154 154
             return $data['file'] instanceof UploadedFile ? $data['file'] : null;
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -139,12 +139,15 @@
 block discarded – undo
139 139
             'name' => null,
140 140
             'code' => null
141 141
         ], $data);
142
-        if (!$map['name'] && !$map['code'])
143
-            return false;
144
-        if ($map['name'])
145
-            $sql['name'] = $map['name'];
146
-        if ($map['code'])
147
-            $sql['code'] = $map['code'];
142
+        if (!$map['name'] && !$map['code']) {
143
+                    return false;
144
+        }
145
+        if ($map['name']) {
146
+                    $sql['name'] = $map['name'];
147
+        }
148
+        if ($map['code']) {
149
+                    $sql['code'] = $map['code'];
150
+        }
148 151
         return [$sql, $map['file'], $map['id']];
149 152
     }
150 153
 
Please login to merge, or discard this patch.