示例#1
0
 /**
  * @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);
 }
示例#2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return Tag::findOrFail($id)->toJson();
 }