/** * Sync tag relation adding new tags as needed * * @param array $skilltags */ public function syncTags(array $skilltags) { SkillsTag::addNeededTags($skilltags); if (count($skilltags)) { $this->skillstags()->sync(SkillsTag::whereIn('tag', $skilltags)->lists('id')->all()); return; } $this->skillstags()->detach(); }
/** * Return the field values from the model * * @param integer $id * @param array $fields * @return array */ protected function fieldsFromModel($id, array $fields) { //$profile = User::findOrFail($id); $profile = SkillsTag::find($id); $fieldNames = array_keys(array_except($fields, ['tags'])); $fields = ['id' => $id]; foreach ($fieldNames as $field) { $fields[$field] = $profile->{$field}; } //$fields['tags'] = $profile->tags()->lists('tag')->all(); return $fields; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $skilltag = SkillsTag::findOrFail($id); $skilltag->delete(); return redirect('/admin/skilltags')->with('status', "Skill tag '{$skilltag->tag}' has been deleted."); }