/** * Save entity updates * * @param Libray $entity * @return void */ public function save(MediaDomainModels\Library $entity) { $library = $this->model->firstOrNew(['id' => $entity->id()->value()]); $library->id = $entity->id()->value(); $library->user_id = $entity->owner()->id()->value(); $description = $entity->description()->value(); $domainAuthors = $entity->sharedTo(); $authors = []; foreach ($description as $key => $value) { $library->{$key} = $value; } $library->save(); foreach ($domainAuthors as $author) { $authors[] = $author->id()->value(); } $library->users()->sync($authors); }