public function addType($type) { $this->removeType(); $type = Types::findOrFail($type); $this->types()->attach($type); }