public function syncAuthors($authors) { Author::addNeededAuthors($authors); $authors = explode(',', $authors); if (count($authors)) { $authors = Author::whereIn('name', $authors)->lists('id')->all(); $this->authors()->sync($authors); return; } $this->author()->detach(); }