فهرست منبع

Update pivot table column

Peter Ragheb 2 سال پیش
والد
کامیت
a8f84d610b

+ 1 - 1
tests/Fixtures/TestPost.php

@@ -22,6 +22,6 @@ class TestPost extends Model
 
     public function tags(): MorphToMany
     {
-        return $this->morphToMany(TestTag::class, 'taggable')->withPivot('order');
+        return $this->morphToMany(TestTag::class, 'taggable')->withPivot('priority');
     }
 }

+ 1 - 1
tests/Fixtures/TestPostFactory.php

@@ -20,7 +20,7 @@ class TestPostFactory extends Factory
     public function pivotTags(): array
     {
         return [
-            'order' => 1
+            'priority' => "high"
         ];
     }
 }

+ 1 - 1
tests/Fixtures/TestTag.php

@@ -17,6 +17,6 @@ class TestTag extends Model
 
     public function posts(): MorphToMany
     {
-        return $this->morphedByMany(TestPost::class, 'taggable')->withPivot('order');
+        return $this->morphedByMany(TestPost::class, 'taggable')->withPivot('priority');
     }
 }

+ 2 - 2
tests/Fixtures/TestTagApiResource.php

@@ -18,8 +18,8 @@ class TestTagApiResource extends JsonResource
         return [
             'id' => $this->id,
             'name' => $this->name ,
-            'order' => $this->whenPivotLoaded('taggables', function () {
-                return $this->pivot->order;
+            'priority' => $this->whenPivotLoaded('taggables', function () {
+                return $this->pivot->priority;
             }),
         ];
     }

+ 2 - 2
tests/Strategies/Responses/UseApiResourceTagsTest.php

@@ -522,7 +522,7 @@ class UseApiResourceTagsTest extends BaseLaravelTest
             $table->string('test_tag_id');
             $table->string('taggable_type');
             $table->string('taggable_id');
-            $table->integer('order');
+            $table->string('priority');
         });
 
         $config = new DocumentationConfig([]);
@@ -548,7 +548,7 @@ class UseApiResourceTagsTest extends BaseLaravelTest
                             [
                                 'id' => 1,
                                 'name' => 'tag 1',
-                                'order' => 1
+                                'priority' => "high"
                             ],
                         ],
                     ],