/** * Index page (get). * * @Get("/", as="pastebin.index") * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function getIndex() { $pb = $this->pasteBin->orderBy('id', 'desc')->whereProtect(false); $count = $pb->count(); $all = $pb->paginate(10); return view('pastebins.index', compact('all', 'count')); }
/** * Create sitemap data. * * @return array */ protected function createSiteMapData() { $data = []; $pasteBin = new M\PasteBin(); $last = $pasteBin->orderBy('id')->get()->last(); $data[] = ['loc' => '/pastebin', 'lastmod' => $last->created_at->format('Y-m-d'), 'changefreq' => 'monthly', 'priority' => '0.7']; $all = $pasteBin->select(['hash', 'created_at'])->where('protect', '=', false)->get(); foreach ($all as $p) { $data[] = ['loc' => "/pastebin/show/{$p->hash}", 'lastmod' => $p->created_at->format('Y-m-d'), 'changefreq' => 'never', 'priority' => '0.4']; } $memo = new M\Memo(); $last = $memo->orderBy('id')->get()->last(); $data[] = ['loc' => '/memo', 'lastmod' => $last->created_at->format('Y-m-d'), 'changefreq' => 'monthly', 'priority' => '0.7']; foreach ($memo->select(['id', 'created_at'])->get() as $m) { $data[] = ['loc' => "/memo/show/{$m->id}", 'lastmod' => $m->created_at->format('Y-m-d'), 'changefreq' => 'never', 'priority' => '0.4']; } foreach ($memo->select('user_sn')->distinct()->get() as $m) { $updated_at = $memo->where('user_sn', '=', $m->user_sn)->get()->last()->updated_at; $data[] = ['loc' => "/memo/user/{$m->user_sn}", 'lastmod' => $updated_at->format('Y-m-d'), 'changefreq' => 'monthly', 'priority' => '0.4']; } return $data; }