/** * Attach Subtypes * @param Entities $entity * @property string $id Subtype Id To Attach * @param Subtypes $subtypes * @return void */ public function attachSubtypes($entity, $subtypes) { foreach ($subtypes as $name) { $subtype_object = Subtypes::make($name); $new_subtype = $this->subtypes->save($subtype_object); $entity->subtypes()->attach($new_subtype->id); } }
public function getByName($name) { return Subtypes::whereName($name)->first(); }