merge() публичный Метод

Merge a resource into this one.
public merge ( Resource $resource ) : void
$resource Resource
Результат void
Пример #1
0
 public function testCanMergeWithAnotherResource()
 {
     $post1 = (object) ['id' => '123', 'foo' => 'bar', 'comments' => [1]];
     $post2 = (object) ['id' => '123', 'baz' => 'qux', 'comments' => [1, 2]];
     $resource1 = new Resource($post1, new PostSerializer4());
     $resource2 = new Resource($post2, new PostSerializer4());
     $resource1->with(['comments']);
     $resource2->with(['comments']);
     $resource1->merge($resource2);
     $this->assertEquals(['type' => 'posts', 'id' => '123', 'attributes' => ['baz' => 'qux', 'foo' => 'bar'], 'relationships' => ['comments' => ['data' => [['type' => 'comments', 'id' => '1'], ['type' => 'comments', 'id' => '2']]]]], $resource1->toArray());
 }