public function saveTagged($data, $diaryId) { $save = Tagged::insert($this->makeInsertableData($data, $diaryId)); if ($save) { return true; } return false; }
protected function sidebarCategory() { if (!Cache::has('_tags')) { $tags = Tagged::join('tags', 'tagged.tag_id', '=', 'tags.id')->select('tags.id', DB::raw('count(tag_id) as total_tags'), 'tags.tag_name')->groupBy('tagged.tag_id')->take(20)->get(); Cache::put('_tags', $tags, 60); } if (!Cache::has('_category')) { $category = Category::get(); Cache::put('_category', $category, 60); } if (!Cache::has('_recent')) { $recent = Diary::where('status', 1)->orderBy('created_at', 'desc')->take(5)->get(['title', 'id']); Cache::put('_recent', $recent, 60); } view()->composer('site.partials.sidebar', function ($view) { $view->with('navData', ['category' => Cache::get('_category'), 'recents' => Cache::get('_recent'), 'tags' => Cache::get('_tags')]); }); }