/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $this->validate($request, ['title' => 'required']); $seo = SeoInfo::findOrFail($id); $seo->update($request->all()); return redirect('admin/seo'); }
public static function seoMap() { $seos = SeoInfo::all(); $map = []; foreach ($seos as $seo) { $map[$seo->tag] = $seo; } return $map; }
public function composerSeo() { view()->composer('common.seo', function ($view) { $path = Request::path(); $seos = SeoInfo::seoMap(); $seo; if (starts_with($path, 'notes')) { $seo = $seos['notes']; } else { if (starts_with($path, 'guide')) { $seo = $seos['guide']; } else { if (starts_with($path, 'activity')) { $seo = $seos['activity']; } else { $seo = $seos['index']; } } } return $view->with('seo', $seo); }); }
/** * Bootstrap any application services. * * @return void */ public function boot() { view()->share('seos', SeoInfo::seoMap()); }