本文整理汇总了PHP中News::where方法的典型用法代码示例。如果您正苦于以下问题:PHP News::where方法的具体用法?PHP News::where怎么用?PHP News::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类News
的用法示例。
在下文中一共展示了News::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified resource.
* GET /frontend/publiccontact/{id}
*
* @param int $id
* @return Response
*/
public function show($id)
{
try {
$contact = Contact::findOrFail($id);
$articles = News::inCategories(Config::get('settings.homepage'))->where('published', '=', 2)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(10)->get();
$featured = News::where('published', '=', 2)->where('featured', '=', 1)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->orderBy('created_at', 'desc')->take(3)->get();
$results = News::inCategories(Config::get('settings.results'))->distinct('permalink')->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->groupBy('permalink')->orderBy('news.created_at', 'desc')->take(10)->get();
$featuredImage = News::inCategories(array(25))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
$didYouKnow = News::inCategories(array(30))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
$magazine = News::inCategories(Config::get('settings.magazine'))->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
$ourComment = News::inCategories(array(17))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
$feed = getFeed('http://bazaznanja.puskice.org/feed/qa.rss', 4);
$poll = null;
$poll = Poll::where('published', '=', '1')->where('end_date', '>', date("Y-m-d H:i:s", strtotime('now')))->where('created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->first();
if (isset($poll->id)) {
$poll->pollOptions;
}
View::share('title', $contact->title . " " . $contact->first_name . " " . $contact->last_name . " | Пушкице | Тачка спајања студената ФОН-а");
$ogimage = Puskice::firstContactImage($contact);
$meta = "\t<meta property='og:image' content='" . $ogimage . "'/>\n\t\t\t\t\t\t<meta property='og:title' content='" . __($contact->title . " " . $contact->first_name . " " . $contact->last_name . " | Пушкице | Тачка спајања студената ФОН-а") . "'/>\n\t\t\t\t\t\t<meta property='fb:app_id' content='355697367892039'/>\n\t\t\t\t\t\t<meta property='og:site_name' content='" . __("Пушкице - ФОН Андерграунд") . "'/>\n\t\t\t\t\t\t<meta property='og:type' content='article'/>\n\t\t\t\t\t\t<meta property='og:url' content='" . _l(Request::root() . "/ljudi/" . $contact->id) . "'/>\n\t\t\t\t\t\t<meta property='og:description' content='" . __($contact->description) . "' />\n\t\t\t\t\t\t<meta name='twitter:card' content='summary_large_image'>\n\t\t\t\t\t\t<meta name='twitter:site' content='" . __("Пушкице - ФОН Андерграунд") . "'>\n\t\t\t\t\t\t<meta name='twitter:creator' content='@puskice'>\n\t\t\t\t\t\t<meta name='twitter:domain' content='puskice.org'>\n\t\t\t\t\t\t<meta name='twitter:app:name:iphone' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:app:name:ipad' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:title' content='" . __($contact->title . " " . $contact->first_name . " " . $contact->last_name . " | Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:description' content='" . __($contact->description) . "'>\n\t\t\t\t\t\t<meta name='twitter:image' content='" . $ogimage . "'>";
$data = array('articles' => $articles, 'featured' => $featured, 'results' => $results, 'ourComment' => $ourComment, 'magazine' => $magazine, 'featuredImage' => $featuredImage, 'didYouKnow' => $didYouKnow, 'feed' => $feed, 'poll' => $poll, 'meta' => $meta, 'contact' => $contact);
$this->setLayout($data);
$this->layout->center = View::make('frontend.content.contact', $data);
} catch (Exception $e) {
App::abort(404);
}
}
示例2: getHome
public function getHome()
{
$datetime = new DateTime();
$now = $datetime->format('m-d-y H:i:s');
$news = News::where('published_at', '>', $now);
return View::make('home', ['news', $news]);
}
示例3: totalNews
/**
* Get total news count
* @param bool $all
* @return mixed
*/
protected function totalNews($all = false)
{
if (!$all) {
return $this->news->where('is_published', 1)->where('lang', $this->getLang())->count();
}
return $this->news->where('lang', $this->getLang())->count();
}
示例4: show
/**
* Display customer profile
*
* @param $profile
* @return Response
*/
public function show($profile)
{
$p = User::where('profile_url', '=', $profile)->where('approved', '=', '0')->first();
$page = Page::where('title', '=', 'faq-customer')->first();
$follow = Follow::where('user', $p->id)->where('hub', '=', 0)->get();
$follow_hub = Follow::where('user', $p->id)->where('artist', '=', 0)->get();
$wall = new \Illuminate\Database\Eloquent\Collection();
$events = new \Illuminate\Database\Eloquent\Collection();
$comments = Comment::where('user', '=', $p->id)->orderBy('created_at', 'desc')->get();
$hidden = unserialize(Cookie::get('hide'));
//dd( Cookie::get('hide') );
if (count($follow) > 0) {
foreach ($follow as $f) {
$s = Song::where('artist', '=', $f->artist)->where('completed', '=', '1')->get();
$e = ArtistEvent::where('artist', '=', $f->artist)->where('date', '>', \Carbon\Carbon::now())->get();
$wall = $wall->merge($s);
$events = $events->merge($e);
}
}
if (count($follow_hub) > 0) {
foreach ($follow_hub as $h) {
$hub = Hub::where('id', '=', $h->hub)->first();
if (!is_null($hub)) {
$artists = User::where('type', '=', 'artist')->where('hub', '=', $hub->id)->get();
$artists_list = [];
$songs = [];
$events = [];
foreach ($artists as $a) {
$artists_list[] = $a->id;
}
if (count($artists_list) > 0) {
$songs = Song::where('completed', '=', '1')->whereIn('artist', $artists_list)->orderBy('created_at', 'desc')->get();
$events = ArtistEvent::whereIn('artist', $artists_list)->get();
}
$news = News::where('hub', '=', $hub->id)->take(3)->get();
$wall = $wall->merge($songs);
$events = $events->merge($events);
}
}
}
$purchased = Purchase::where('customer', '=', $p->id)->get();
foreach ($purchased as $pp) {
$song_purchased = Song::withTrashed()->where('id', '=', $pp->song)->get();
$download = Download::where('customer', '=', $p->id)->where('song', '=', $pp->song)->first();
$song_purchased[0]->purchased = true;
if (isset($download)) {
$song_purchased[0]->link = $download->url;
}
$wall = $wall->merge($song_purchased);
}
$wall->sortByDesc('created_at');
if (!isset($news)) {
$news = null;
}
return View::make('customer.profile-new', ['profile' => $p, 'wall' => $wall, 'page' => $page, 'events' => $events, 'comments' => $comments, 'hidden' => $hidden, 'news' => $news]);
}
示例5: getSingle
/**
* Display the specified resource.
* GET /api\apisubject/{id}
*
* @param int $id
* @return Response
*/
public function getSingle($id)
{
try {
$article = News::where('published', '=', 2)->where('post_type', '=', 3)->where('id', '=', $id)->firstOrFail();
$article->subjects;
$article->newsContacts;
$article->files;
$this->googleAnalytics('/subjects/single/' . $id);
return Response::json($article);
} catch (Exception $e) {
return Response::json(array('status' => 'fail'));
}
}
示例6: getSingle
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function getSingle($id)
{
try {
$news = News::where('id', '=', $id)->where('post_type', '=', 1)->where('published', '=', 2)->where('created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->firstOrFail();
$news->view_count++;
$news->save();
$news->short_content = __($news->short_content);
$news->long_content = __($news->long_content);
$this->googleAnalytics('/news/single/' . $id);
return Response::json($news);
} catch (Exception $e) {
return Response::json(array('status' => 'fail'));
}
}
示例7: getSingle
public function getSingle($id)
{
try {
$news = News::where('post_type', 2)->where(function ($query) use($id) {
return $query->where('id', '=', $id)->orWhere('permalink', '=', $id);
})->firstOrFail();
$news->view_count++;
$news->save();
$this->googleAnalytics('/pages/single/' . $id);
return Response::json($news);
} catch (Exception $e) {
var_dump($e->getMessage());
return Response::json(array('status' => 'fail'));
}
}
示例8: getIndex
/**
* Display a listing of the resource.
*
* @return Response
*/
public function getIndex()
{
if (Session::get('user_level') < Config::get('cms.viewPages')) {
return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning');
}
$this->setLayout();
if (Input::get('q')) {
$news = News::where('post_type', '=', 2)->where(function ($query) {
$query->where('title', 'LIKE', '%' . Input::get('q') . '%')->orwhere('long_content', 'LIKE', '%' . Input::get('q') . '%');
})->orderBy('created_at', 'desc')->paginate(20);
} else {
$news = News::where('post_type', '=', 2)->orderBy('created_at', 'desc')->paginate(20);
}
View::share('title', __(Lang::get('admin.pages')));
View::share('news', $news);
$this->layout->content = View::make('backend.pages.index');
}
示例9: getIndex
/**
* Display a listing of the resource.
*
* @return Response
*/
public function getIndex()
{
View::share('title', __(Lang::get('admin.dashboard')));
$news = News::where('post_type', '=', 1)->orderBy('created_at', 'desc')->take(5)->get();
$comments = Comment::orderBy('created_at', 'desc')->take(5)->get();
$users = User::orderBy('created_at', 'desc')->take(5)->get();
$files = Files::orderBy('created_at', 'desc')->take(5)->get();
$categories = Category::orderBy('created_at', 'desc')->take(5)->get();
$pages = News::where('post_type', '=', 2)->orderBy('created_at', 'desc')->take(5)->get();
View::share('news', $news);
View::share('comments', $comments);
View::share('users', $users);
View::share('files', $files);
View::share('pages', $pages);
View::share('categories', $categories);
$this->setLayout();
$this->layout->content = View::make('backend.content.dashboard');
}
示例10: show
public function show($slug)
{
$hub = Hub::where('slug', '=', $slug)->first();
if (!is_null($hub)) {
$artists = User::where('type', '=', 'artist')->where('hub', '=', $hub->id)->get();
$artists_list = [];
$songs = [];
$events = [];
foreach ($artists as $a) {
$artists_list[] = $a->id;
}
if (count($artists_list) > 0) {
$songs = Song::where('completed', '=', '1')->whereIn('artist', $artists_list)->orderBy('created_at', 'desc')->get();
$events = ArtistEvent::whereIn('artist', $artists_list)->get();
}
$news = News::where('hub', '=', $hub->id)->take(3)->get();
return View::make('hubs.main', ['hub' => $hub, 'news' => $news, 'artists' => $artists, 'songs' => $songs, 'events' => $events]);
}
App::abort(404);
}
示例11: get_index
/**
* Make the index view
*/
public function get_index()
{
$fname = "";
if (Auth::check()) {
$fname = User::getFirstName(Auth::user()->get()->cid);
}
//Pull category data
$publicCategories = Category::where('hidden', '!=', 1)->get();
$categories = Category::all();
//Figure out which categories have children
$categoryChildren = array();
foreach ($categories as $categoryParent) {
if (Category::isParent($categoryParent->id)) {
$categoryChildren[$categoryParent->id] = Category::getChildren($categoryParent->id);
}
}
//Get our news
$news = News::where("visible", "=", 1)->orderBy("updated_at", "DESC")->get();
return View::make('index')->with(array('fname' => $fname, 'categories' => $categories, 'categoryChildren' => $categoryChildren, 'publicCategories' => $publicCategories, 'news' => $news));
}
示例12: rss
public function rss($language)
{
// Définition de la langue :
if (!$this->setupLanguage($language)) {
App::abort(404);
}
// Variables :
// Details :
$header = '<?xml version="1.0" encoding="UTF-8"?>';
// News (dans un try catch pour gérer les erreurs) :
try {
$languages = Language::where('_url', '=', $language)->firstOrFail();
$news = News::where('_langue', '=', $languages->_id)->get();
$news = $news->sortBy('_date')->take(30);
} catch (Exception $e) {
App::abort(404);
}
// Renvoi de la vue avec les news et l'en-tête :
$page = $this->layout->content = View::make('pages.news.fluxXML', array("news" => $news, "header" => $header));
return Response::make($page, '200')->header('Content-Type', 'text/xml');
}
示例13: search
public function search($language)
{
if (!$this->setupLanguage($language)) {
App::abort(404);
}
// VARIABLES :
// Pages :
try {
$languages = Language::where('_url', '=', $language)->firstOrFail();
$page = Pages::where('_language', $languages->_id)->where("_name", "=", "search")->get()->first();
} catch (Exception $e) {
App::abort(500);
}
// Request :
$accentARemplacer = array('Š' => 'S', 'š' => 's', 'Ž' => 'Z', 'ž' => 'z', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'Ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y', 'þ' => 'b', 'ÿ' => 'y');
$request = trim(Input::get("q"));
$requestWithoutAccent = strtr($request, $accentARemplacer);
$requestWithAccent = $request;
$request_explode = array_unique(array_merge(explode(" ", $requestWithoutAccent), explode(" ", $requestWithAccent)));
// Details :
$data = array("situation" => array("title" => $page->_title, "description" => $page->_description), "position" => array($page->_title => " ", $request => ""));
//
$results = array();
if (count($request_explode) > 0) {
foreach ($request_explode as $key => $value) {
$pages = Pages::where("_keywords", "LIKE", '%' . $value . '%')->orWhere('_title', "LIKE", '%' . $value . '%')->orWhere('_name', "LIKE", '%' . $value . '%')->orWhere('_description', "LIKE", '%' . $value . '%')->get();
$news = News::where('_langue', '=', $languages->_id)->where("_extract", "LIKE", '%' . $value . '%')->orWhere('_content', "LIKE", '%' . $value . '%')->orWhere('_title', "LIKE", '%' . $value . '%')->get();
if (count($pages) > 0) {
$results["pages"] = $pages;
}
if (count($news) > 0) {
$results["news"] = $news;
}
}
} else {
App::abort(404);
}
$this->layout->content = View::make('pages.search.search', array('data' => $data, "page" => $page, "language" => $languages, 'request' => $request, 'results' => $results));
}
示例14: getMyProfile
public function getMyProfile()
{
try {
View::share('title', "Моје Пушкице | Пушкице | Тачка спајања студената ФОН-а");
$user = User::findOrFail(Session::get('id'));
$articles = News::inCategories(Config::get('settings.homepage'))->where('published', '=', 2)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(10)->get();
$featured = News::where('published', '=', 2)->where('featured', '=', 1)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->orderBy('created_at', 'desc')->take(3)->get();
$results = News::inCategories(Config::get('settings.results'))->distinct('permalink')->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->groupBy('permalink')->orderBy('news.created_at', 'desc')->take(10)->get();
$featuredImage = News::inCategories(array(25))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
$didYouKnow = News::inCategories(array(30))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
$magazine = News::inCategories(Config::get('settings.magazine'))->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
$ourComment = News::inCategories(array(17))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
$feed = getFeed('http://bazaznanja.puskice.org/feed/qa.rss', 4);
$poll = null;
$poll = Poll::where('published', '=', '1')->where('end_date', '>', date("Y-m-d H:i:s", strtotime('now')))->where('created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->first();
if (isset($poll->id)) {
$poll->pollOptions;
}
$ogimage = Config::get('settings.defaultImage');
$meta = "\t<meta property='og:image' content='" . $ogimage . "'/>\n\t\t\t\t\t\t<meta property='og:title' content='" . __("Моје Пушкице | Пушкице | Тачка спајања студената ФОН-а") . "'/>\n\t\t\t\t\t\t<meta property='fb:app_id' content='355697367892039'/>\n\t\t\t\t\t\t<meta property='og:site_name' content='" . __("Пушкице - ФОН Андерграунд") . "'/>\n\t\t\t\t\t\t<meta property='og:type' content='article'/>\n\t\t\t\t\t\t<meta property='og:url' content='" . _l(Request::root() . "/login/my-profile") . "'/>\n\t\t\t\t\t\t<meta property='og:description' content='" . __("Креирајте свој профил на Пушкицама и остварите приступ бројним погодностима које нудимо студентима") . "' />\n\t\t\t\t\t\t<meta name='twitter:card' content='summary_large_image'>\n\t\t\t\t\t\t<meta name='twitter:site' content='" . __("Пушкице - ФОН Андерграунд") . "'>\n\t\t\t\t\t\t<meta name='twitter:creator' content='@puskice'>\n\t\t\t\t\t\t<meta name='twitter:domain' content='puskice.org'>\n\t\t\t\t\t\t<meta name='twitter:app:name:iphone' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:app:name:ipad' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:title' content='" . __("Моје Пушкице | Пушкице | Тачка спајања студената ФОН-а") . "'>\n\t\t\t\t\t\t<meta name='twitter:description' content='" . __("Креирајте свој профил на Пушкицама и остварите приступ бројним погодностима које нудимо студентима") . "'>\n\t\t\t\t\t\t<meta name='twitter:image' content='" . $ogimage . "'>";
$data = array('articles' => $articles, 'featured' => $featured, 'results' => $results, 'ourComment' => $ourComment, 'magazine' => $magazine, 'featuredImage' => $featuredImage, 'didYouKnow' => $didYouKnow, 'feed' => $feed, 'poll' => $poll, 'meta' => $meta, 'user' => $user);
$this->setLayout($data);
$this->layout->center = View::make('frontend.content.profile', $data);
//$this->layout->carousel = View::make('frontend.carousel', $data);
$this->layout->boxes = View::make('frontend.boxes', $data);
$this->layout->imageOfTheWeek = View::make('frontend.sidebar.imageOfTheWeek', $data);
$this->layout->didYouKnow = View::make('frontend.sidebar.didYouKnow', $data);
$this->layout->twitter = View::make('frontend.sidebar.twitter');
$this->layout->poll = View::make('frontend.sidebar.poll', $data);
} catch (Exception $e) {
return Redirect::to('login')->with('message', __("Потребно је да се прво улогујете"))->with('notif', 'success');
}
}
示例15: newsDetail
public function newsDetail($id)
{
$news = News::where('id', '=', $id)->get();
//dd($news[0]->title);
return View::make('home.news-detail')->with('news', $news[0]);
}