/** * @param $primaryID Primary ID of Font to update Tags on * @param $tags Array of Tags (as strings) */ private function updateTagWeights($primaryID, $tags) { $font = Font::find($primaryID); foreach ($tags as $tag) { $tagWeight = TagWeight::firstOrCreate(['font_id' => $primaryID, 'tagName' => $tag]); if ($tagWeight->tagWeight == 4) { $tagModel = Tag::firstOrCreate(['tag' => $tag]); DB::table('font_tags')->insert(['font_id' => $font->id, 'tag_id' => $tagModel->id]); $tagModel->usage = $tagModel->usage + 1; $tagModel->save(); } $tagWeight->tagWeight = $tagWeight->tagWeight + 1; $tagWeight->save(); } return json_encode($tags); }
public function getTagWeights($id) { return Font::findOrFail($id)->tagWeights()->get()->toJson(); }
/** * Run the database seeds. * * @return void */ public function run() { foreach ($this->TABLE_6 as $font) { Font::create(array('fontName' => $font['fontName'], 'fontAuthor' => $font['fontAuthor'], 'fileType' => $font['fileType'], 'fileName' => $font['fileName'], 'defaultFontFileName' => $font['defaultFontFileName'], 'fontType' => $font['fontType'], 'fontTypeDetailed' => $font['fontTypeDetailed'], 'fontLicense' => $font['fontLicense'], 'fontURL' => $font['fontURL'])); } }