public function read(Request $request)
 {
     $page = 'noticias-e-releases';
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     $pages = Pages::where('slug', '=', $page)->first();
     $date = $request->year . '-' . $request->month . '-' . $request->day;
     $newsAndReleases = NewsAndReleases::where('date', '=', $date)->where('slug', '=', $request->slug)->first();
     array_set($newsAndReleases, "date", Carbon::createFromFormat('Y-m-d', $newsAndReleases->date));
     //INCREMENT
     NewsAndReleases::find($newsAndReleases->newsAndReleasesId)->increment('read');
     //MORE NEWS AND RELEASES
     $moreNewsAndReleases = NewsAndReleases::orderBy('date', 'desc')->where('newsAndReleasesId', '!=', $newsAndReleases->newsAndReleasesId)->limit(2)->addSelect('title')->addSelect('date')->addSelect('slug')->get();
     foreach ($moreNewsAndReleases as $item) {
         array_set($item, "date", Carbon::createFromFormat('Y-m-d', $item->date));
     }
     return view('website.newsAndReleases.intern')->with(compact('page', 'pages', 'websiteSettings', 'newsAndReleases', 'moreNewsAndReleases'));
 }
コード例 #2
0
 public function post(Request $request)
 {
     $page = 'busca';
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     $pages = Pages::where('slug', '=', $page)->first();
     if (!$request->inputSearch) {
         return redirect('/')->with('message', 'Informe algum conteúdo para a busca.');
     }
     $blog = Blog::where('title', 'LIKE', '%' . $request->inputSearch . '%')->orWhere('subtitle', 'LIKE', '%' . $request->inputSearch . '%')->orderBy('date', 'desc')->get();
     foreach ($blog as $item) {
         array_set($item, "date", Carbon::createFromFormat('Y-m-d', $item->date));
     }
     $newsAndReleases = NewsAndReleases::where('title', 'LIKE', '%' . $request->inputSearch . '%')->orWhere('subtitle', 'LIKE', '%' . $request->inputSearch . '%')->orderBy('date', 'desc')->get();
     foreach ($newsAndReleases as $item) {
         array_set($item, "date", Carbon::createFromFormat('Y-m-d', $item->date));
     }
     return view('website.search.index')->with(compact('page', 'pages', 'websiteSettings', 'request', 'blog', 'newsAndReleases'));
 }