App\Repositories\TagRepository::getById PHP Method

getById() public method

Get tag by id.
public getById ( $id ) : mixed
$id
return mixed
    public function getById($id)
    {
        $tag = $this->model->find($id);
        if (!is_null($tag)) {
            $tag->hot++;
            $tag->update();
        }
        return $tag;
    }

Usage Example

 /**
  * Redirect to tags with default tag.
  *
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function showTag($id)
 {
     $tag = $this->tag->getById($id);
     return redirect('/tags')->with('default', $tag);
 }