public function vacations($vacation) { if ($vacation == 'winter') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Зима')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } elseif ($vacation == 'spring') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Весна')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } elseif ($vacation == 'summer') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Лето')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } elseif ($vacation == 'autumn') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Осень')->orderBy('programs.id', 'desc')->select('programs.id as id', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } elseif ($vacation == 'weekend') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Выходной')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } elseif ($vacation == 'festival') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Фестиваль')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } else { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } $all_news = News::where('active', '=', '1')->get(); $monthes = array(1 => 'Января', 2 => 'Февраля', 3 => 'Марта', 4 => 'Апреля', 5 => 'Мая', 6 => 'Июня', 7 => 'Июля', 8 => 'Августа', 9 => 'Сентября', 10 => 'Октября', 11 => 'Ноября', 12 => 'Декабря'); if (Auth::check()) { $user = Auth::user()->name; } else { $user = '******'; } return view('index', ['programs' => $programs, 'monthes' => $monthes, 'all_news' => $all_news, 'user' => $user]); }
public function index($token) { if ($token === 'W2Xcoiq28sLNasiszA819qgLk42CTc5b') { $addressees = Model::all(); $news = News::getForDelivery(); $tenders = Tender::getForDelivery(); $vacancies = Vacancy::getForDelivery(); $shares = Share::getForDelivery(); $expert_advices = ExpertAdvice::getForDelivery(); foreach ($addressees as $addressee) { $params['title'] = $addressee->locale . '_title'; $params['text'] = $addressee->locale . '_text'; $params['locale'] = $addressee->locale; $addressee->news && count($news) ? $params['delivery']['news'] = $news : null; $addressee->tenders && count($tenders) ? $params['delivery']['tenders'] = $tenders : null; $addressee->vacancies && count($vacancies) ? $params['delivery']['vacancies'] = $vacancies : null; $addressee->shares && count($shares) ? $params['delivery']['shares'] = $shares : null; $addressee->expert_advices && count($expert_advices) ? $params['delivery']['expert_advices'] = $expert_advices : null; if (isset($params['delivery'])) { Mail::send('emails.delivery', $params, function ($message) use($addressee) { $from_address = MailConfig::first(); $from_name = Config::get('mail.from'); $message->from($from_address->feedback_mail, $from_name['name']); $message->to($addressee->email)->subject(trans('front-end' . DS . 'emails' . DS . 'delivery.subject')); }); } unset($params); } News::where('sended', 0)->update(['sended' => 1]); Tender::where('sended', 0)->update(['sended' => 1]); Vacancy::where('sended', 0)->update(['sended' => 1]); Share::where('sended', 0)->update(['sended' => 1]); ExpertAdvice::where('sended', 0)->update(['sended' => 1]); } }
public function viewNewsAction() { if (Request::has('id')) { $news = News::where('id', '=', Request::input('id'))->first(); return view('base.view_news', ['news' => $news]); } }
public function getView(Request $request) { $news = News::where("slug", $request->get('slug'))->first(); if ($news->image->count()) { $news->images = $news->image->name; } return response()->json($news); }
public function index(Request $request) { if ($request->input('tag') == '全部动态' || $request->input('tag') == null) { return view('news.index')->withNavSelection(3)->withTagSelection("全部动态")->withNews(News::paginate(10)); } else { return view('news.index')->withNavSelection(3)->withTagSelection($request->input('tag'))->withNews(News::where('tag', $request->input('tag'))->paginate(10)); } }
public function newsShow($slug) { $visitor = News::where('is_hide', 0)->where('slug', $slug)->where("created_at", "like", $this->year . "%")->firstOrFail(); $visitor->views++; $visitor->save(); $news = News::where('is_hide', 0)->where('slug', $slug)->where("created_at", "like", $this->year . "%")->firstOrFail(); return view('conference_information.detail_news', compact('news'))->with('year', $this->curYear); }
public function getArticle($slug) { try { $article = News::where('slug', '=', $slug)->firstOrFail(); return view('news-single', ['post' => $article]); } catch (\Exception $e) { return redirect('/news'); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $newscount = News::where('id', '!=', 'null')->count(); $chartercount = Charters::where('id', '!=', 'null')->count(); $userscount = User::where('id', '!=', 'null')->count(); $categories = \DB::table('news_categories')->lists('name', 'id'); $publisher = \DB::table('users')->lists('name', 'id'); return view('backend.home', compact('newscount', 'userscount', 'chartercount'))->with(['categories' => $categories, 'publisher' => $publisher]); }
public function show($id) { if ($oNews = News::where('id', $id)->with(['comments'])->get()) { $aRet = ['success' => 'true', 'news' => $oNews->toArray()]; } else { $aRet = ['success' => 'false', 'error' => 'cant find news with this id']; } return response()->json($aRet); }
public function index(Request $request) { $tag = $request->input('tag'); if ($tag == null || $tag == "全部分类") { return view('admin.news.index')->withNews(News::paginate(10))->withTag($tag); } else { return view('admin.news.index')->withNews(News::where('tag', $tag)->paginate(10))->withTag($tag); } }
public function delete($id) { $entry = News::find($id); if (isset($entry)) { News::where('id', $id)->update(array('trash' => 1)); return \Redirect::route('news')->with('success', $entry->title . ' deleted succesfully!'); } else { return \Redirect::route('news')->with('error', 'Failed to delete, invalid credentials.'); } }
public function getIndex() { $banners = File::where('img_type', 'banner')->where("created_at", "like", $this->year . "%")->get(); $speakers = Speaker::where("created_at", "like", $this->year . "%")->limit(4)->get(); $cooperations = File::where('img_type', 'cooperation')->where("created_at", "like", $this->year . "%")->get(); $supporteds = File::where('img_type', 'supported')->where("created_at", "like", $this->year . "%")->get(); $organizeds = File::where('img_type', 'organized')->where("created_at", "like", $this->year . "%")->get(); $news = News::where('is_hide', 0)->where("created_at", "like", $this->year . "%")->orderBy('id', 'desc')->limit(4)->get(); return view('frontend.home.index', compact('banners', 'speakers', 'cooperations', 'supporteds', 'organizeds', 'news'))->with('year', $this->curYear); }
/** * Store a newly created resource in storage. * * @return Response */ public function storeComment(Comments $comment, CreateCommentRequest $request) { /*$this->validate($request, [ 'nama' => 'required', 'email' => 'required|email', 'komentar' => 'required' ]);*/ $news_slug = News::where('id', $request->input('news_id'))->first()->slug; $comment->create($request->all()); return redirect()->route('news_path', [$news_slug, '#comments-box']); }
public function comment($slug) { $news2 = DB::table('news')->leftJoin('users', 'news.publisher', '=', 'users.id')->leftJoin('news_categories', 'news.category', '=', 'news_categories.id')->select('news.title', 'news.slug', 'news_categories.name as category', 'news.s_content', 'users.name as publisher', 'news.image', 'news.created_at', 'users.image as image2')->get(); $news = News::where('slug', '=', $slug)->leftJoin('users', 'news.publisher', '=', 'users.id')->leftJoin('news_categories', 'news.category', '=', 'news_categories.id')->select('news.title', 'news.slug', 'news.category', 'news.s_content', 'news.content', 'users.name as publisher', 'news.image', 'news.created_at')->get(); $com_id = News::first(); $comment = new Comment(); $comment->body = \Input::get('comment'); $comment->poster = \Input::get('author'); $comment->commentable_id = $com_id->id; $com_id->comments()->save($comment); return \Redirect::back()->with(['news' => $news, 'news2' => $news2]); }
public function postDelete(Request $request, $id) { $item = News::where('id', $id)->first(); if ($item != null) { $item->delete(); $msg = "Новость \"" . $item->title . "\" удалена."; return redirect('admin/news')->with('msg', $msg); } else { $msg = "Новости с id = " . $id . " не существует."; return redirect('admin/news')->with('msg', $msg); } }
/** * Отображает одну новость. * * @param int $id * @return \Illuminate\Http\Response */ public function getShow($id) { // Получаем новость из БД $data['news'] = News::find($id); if (!empty($data['news'])) { // Последние 3 новости $data['latest_news'] = News::where('id', '<>', $id)->orderBy('created_at', 'DESC')->take(3)->get(); // Отображаем представление return view('marketing.news.show', $data); } else { abort(404); } }
public function getAbout(Request $request) { if ($request->input('id') == null) { $news = News::all(); $about = About::first(); return view('home.about')->with(['news' => $news, 'about' => $about]); } else { $item = News::where('id', $request->input('id'))->first(); if ($item == null) { return redirect('about'); } return view('home.news')->with('item', $item); } }
public function show($name) { if (is_numeric($name)) { $n = News::where('id', '=', $name)->first(); if (is_null($n)) { return \Redirect::to('404'); } return \View::make('news')->with('entry', $n); } else { $n = News::where('name', '=', $name)->first(); if (is_null($n)) { return \Redirect::to('404'); } return \View::make('news')->with('entry', $n); } }
public function getItem($title) { $item = News::where('sef', '=', $title)->first(); /* ->get(); возвращает коллекцию и для доступа к индивидуальным полям объекта надо сделать foreach @foreach ($news as $item) {{ $item->id }} @endforeach ->first(); а вот это возвращает один объект и можно сразу писать так $item->category_id */ $previous = News::where('id', '<', $item->id)->orderBy('id', 'desc')->first(); $next = News::where('id', '>', $item->id)->orderBy('id', 'asc')->first(); $category = Category::where('id', $item->category_id)->first(); return view('news.item')->withCategory($category)->withItem($item)->withPrevious($previous)->withNext($next); }
/** * Действие для поиска и отображения результатов. * * @return Response */ public function getIndex(Request $request) { // Если не задан поиск $q = trim($request->get('q')); if (!$q or strlen($q) < 3) { return view('marketing.search.index'); } // Начинаем поиск // по новостям if (in_array('news', $this->sources)) { $data['news'] = News::where('title', 'LIKE', "%{$q}%")->orWhere('full_text', 'LIKE', "%{$q}%")->orderBy('created_at', 'DESC')->get(); } // По прудуктам Sika if (in_array('products_sika', $this->sources)) { $data['products_sika'] = ProductSika::where(function ($query) use($q) { $query->where('title', 'LIKE', "%{$q}%")->orWhere('description', 'LIKE', "%{$q}%"); })->whereEnabled(TRUE)->orderBy('created_at', 'DESC')->with(['category' => function ($q) { $q->whereEnabled(TRUE); }])->get(); } // По прудуктам Sfs if (in_array('products_sfs', $this->sources)) { $data['products_sfs'] = ProductSfs::where(function ($query) use($q) { $query->where('title', 'LIKE', "%{$q}%")->orWhere('description_small', 'LIKE', "%{$q}%")->orWhere('description_full', 'LIKE', "%{$q}%"); })->whereEnabled(TRUE)->orderBy('created_at', 'DESC')->with(['category' => function ($q) { $q->whereEnabled(TRUE); }])->get(); } // По прудуктам Primer if (in_array('products_primer', $this->sources)) { $data['products_primer'] = ProductPrimer::where(function ($query) use($q) { $query->where('title', 'LIKE', "%{$q}%")->orWhere('description_small', 'LIKE', "%{$q}%")->orWhere('description_full', 'LIKE', "%{$q}%"); })->whereEnabled(TRUE)->orderBy('created_at', 'DESC')->with(['category' => function ($q) { $q->whereEnabled(TRUE); }])->get(); } // Всего результатов $resCount = 0; foreach ($data as $value) { $resCount += count($value); } $data['res_count'] = $resCount; return view('marketing.search.index', $data); }
public function postUserRegister(Request $request) { $validator = $this->validator($request->all()); $email = User::where('email', '=', $request->input('email'))->count(); $all_news = News::where('active', '=', '1')->get(); if ($email > 0) { $message = 'Пользователь с таким e-mail уже существует'; return view('auth.register')->with('message', $message)->with('all_news', $all_news); } if ($validator->fails()) { $message = 'Вы ввели неверные данные'; return view('auth.register')->with('message', $message)->with('all_news', $all_news); } $user = $this->create($request->all()); $email = $user->email; $id = $user->id; $user->delivery = Input::get('delivery'); $user->data_processing = Input::get('data_processing'); $user->save(); $message = 'Вы зарегистрировались на нашем сайте. Вам на почту поступило письмо с подтверждением Вашего почтового адреса.'; $message_type = 'not_confirmed'; return view('emails.confirmation')->with('message', $message)->with('message_type', $message_type)->with('email', $email)->with('all_news', $all_news)->with('id', $id); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function read($id) { $id = preg_replace("/[^0-9]/", '', $id); $item = App\News::where('id', '=', $id)->get(); return view('showarticle', ['item' => $item]); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($title) { $currentNews = News::where('title_en', $title)->get(); $comments = Comments::where('id', '=', 'comment_id')->get(); return view('CurrentNews', ['currentNews' => $currentNews, 'comments' => $comments]); }
public function hugleidingar() { $data['title'] = 'Hugleiðingar'; $data['items'] = \App\News::where('status', '>', 0)->where('type', 'thought')->orderBy('published_at', 'DESC')->orderBy('order')->get(); return view('frontend.overview')->with($data); }
/** * Show the form for editing the specified resource. * * @param string $slug * @return Response */ public function edit($slug) { $article = News::where('slug', $slug)->first(); if ($article) { return View::make('news/edit', compact('article')); } else { throw new \Exception('Artikel is niet gevonden in de database.'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { News::where('id', '=', $id)->delete(); flash()->success('Your news has been deleted'); return redirect()->action('AuthExtendedController@news'); }
public function updateNewsAction() { News::where('is_imported', '=', '1')->delete(); $url = "http://rybaksverdlovsk.at.ua/news/rss/"; $rss = simplexml_load_file($url); foreach ($rss->channel->item as $item) { $namespaces = $item->getNameSpaces(true); News::create(array('title' => $item->title, 'description' => $item->description, 'content' => $item->children($namespaces['content'])->encoded, 'created_at' => strtotime($item->pubDate))); } return redirect()->back(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function terms() { $news2 = DB::table('news')->leftJoin('users', 'news.publisher', '=', 'users.id')->leftJoin('news_categories', 'news.category', '=', 'news_categories.id')->select('news.title', 'news.slug', 'news_categories.name as category', 'news.s_content', 'users.name as publisher', 'news.image', 'news.created_at', 'users.image as image2')->get(); $news = News::where('id', '!=', 'null')->get(); return view('frontend.about.terms')->with(['news' => $news, 'news2' => $news2]); }
/** * Отображает страницу с картой сайта * */ public function getSitemapPage(Request $request) { $cats = Cache::remember('cats', 10, function () { return Cat::roots()->get(); }); $pages = Pages::all(); $news = Cache::remember('news_sitemap', 3600, function () { $news = News::where('date_publish', '<=', Carbon::parse(Carbon::now())->format('Y-m-d H:i'))->where('category', '=', 0)->get(); return $news; }); $ogoloshenia = News::where('date_publish', '<=', Carbon::parse(Carbon::now())->format('Y-m-d H:i'))->where('category', '=', 1)->get(); return view('auction.sitemap', ['categories' => $cats, 'currentCategory' => null, 'request' => $request, 'pages' => $pages, 'news' => $news, 'ogoloshenia' => $ogoloshenia]); }
/** * Reorder items * * @param items list * @return items from @param */ public function getReorder(ReorderRequest $request) { $list = $request->list; $items = explode(",", $list); $order = 1; foreach ($items as $value) { if ($value != '') { News::where('id', '=', $value)->update(array('position' => $order)); $order++; } } return $list; }