本文整理汇总了PHP中News::inCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP News::inCategories方法的具体用法?PHP News::inCategories怎么用?PHP News::inCategories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类News
的用法示例。
在下文中一共展示了News::inCategories方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getCategory
public function getCategory($id)
{
$this->googleAnalytics('/news/category/' . $id);
$news = News::inCategories(array($id))->where('post_type', '=', 1)->where('published', '=', 2)->where('created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->distinct('permalink')->groupBy('news.id')->orderBy('created_at', 'desc')->paginate(20);
/*$news = News::whereHas('newsCategories', function($q) use($id)
{
$q->where('category_id', $id);
})->where('post_type', 1)->orderBy('created_at', 'desc')->paginate(20);*/
foreach ($news as $key => $article) {
$news[$key]->long_content = __($article->long_content);
$news[$key]->short_content = __($article->short_content);
}
return Response::json($news);
}
示例3: getAdminOnly
public function getAdminOnly()
{
if (Session::get('user_level') < Config::get('cms.viewNews')) {
return Redirect::to(_l(URL::action('AdminHomeController@getIndex')));
}
$selectCategories = Category::where('tag', '=', 0)->get();
View::share('selectCategories', $selectCategories);
$this->setLayout();
if (Input::get('cat')) {
$news = News::inCategories(array(Input::get('cat')))->where('post_type', '=', 1);
} else {
$news = News::where('post_type', '=', 1);
}
if (Input::get('q')) {
$news = $news->where('published', '=', '1')->where('post_type', '=', 1)->where(function ($query) {
$query->where('title', 'LIKE', '%' . Input::get('q') . '%')->orwhere('long_content', 'LIKE', '%' . Input::get('q') . '%');
})->orderBy('created_at', 'desc')->paginate(20);
}
$news = $news->where('published', '=', '1')->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->paginate(20);
View::share('title', __(Lang::get('admin.news')));
View::share('news', $news);
$this->layout->content = View::make('backend.news.index');
}
示例4: category
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function category($permalink = "")
{
$category = Category::where('permalink', '=', $permalink)->firstOrFail();
$news = News::inCategories(array($category->id))->where('published', '=', 2)->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->paginate(10);
return Response::make(RSSGenerator::rss($news), 200, array('Content-type' => 'text/xml'));
}
示例5: newMeme
public function newMeme()
{
$title = "Нови постер | Пушкице";
View::share('title', strip_tags($title));
$memes = Meme::all();
Session::put('antispam1', rand(0, 20));
Session::put('antispam2', rand(0, 20));
//$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'))->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(4)->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;
}
$meta = "\t<meta property='og:image' content='" . Config::get('settings.defaultImg') . "'/>\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() . "/memes/new") . "'/>\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='" . __(strip_tags("Меме генератор")) . "'>\n\t\t\t\t\t\t<meta name='twitter:image' content='" . Config::get('settings.defaultImg') . "'>";
$data = array('featured' => $featured, 'results' => $results, 'ourComment' => $ourComment, 'magazine' => $magazine, 'featuredImage' => $featuredImage, 'didYouKnow' => $didYouKnow, 'feed' => $feed, 'poll' => $poll, 'meta' => $meta, 'memes' => $memes);
$this->setLayout($data);
$this->layout->center = View::make('frontend.content.newMeme', $data);
}
示例6: postKviz
public function postKviz()
{
$rules = array('kadsuculi' => 'Required', 'vladar' => 'Required', 'zgrada' => 'Required', 'konasvoli' => 'Required', 'nikadniste' => 'Required', 'promene' => 'Required', 'stavoli' => 'Required', 'epsilon' => 'Required', 'clan' => 'Required', 'biliclan' => 'Required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to(_l(URL::to('/') . '/kviz'))->withErrors($validator)->withInput();
} else {
$kviz = new Kviz();
$kviz->kadsuculi = Input::get('kadsuculi');
$kviz->vladar = is_array(Input::get('vladar')) ? serialize(Input::get('vladar')) : '';
$kviz->zgrada = Input::get('zgrada');
$kviz->konasvoli = is_array(Input::get('konasvoli')) ? serialize(Input::get('konasvoli')) : '';
$kviz->nikadniste = is_array(Input::get('nikadniste')) ? serialize(Input::get('nikadniste')) : '';
$kviz->promene = Input::get('promene');
$kviz->stavoli = is_array(Input::get('stavoli')) ? serialize(Input::get('stavoli')) : '';
$kviz->epsilon = Input::get('epsilon');
$kviz->biliclan = Input::get('biliclan');
$kviz->clan = is_array(Input::get('clan')) ? serialize(Input::get('clan')) : '';
$kviz->save();
try {
$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();
$results = News::inCategories(Config::get('settings.results'))->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(4)->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();
$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', "Квиз | Пушкице");
$ogimage = Config::get('settings.defaultImage');
$meta = "\t<meta property='og:image' content='" . $ogimage . "'/>\n\t\t\t\t\t\t\t<meta property='og:title' content='" . __("Квиз | Пушкице") . "'/>\n\t\t\t\t\t\t\t<meta property='fb:app_id' content='355697367892039'/>\n\t\t\t\t\t\t\t<meta property='og:site_name' content='" . __("Пушкице - ФОН Андерграунд") . "'/>\n\t\t\t\t\t\t\t<meta property='og:type' content='article'/>\n\t\t\t\t\t\t\t<meta property='og:url' content='" . _l(Request::root() . "/kviz/") . "'/>\n\t\t\t\t\t\t\t<meta property='og:description' content='" . __("Квиз за ФОН-овце") . "' />\n\t\t\t\t\t\t\t<meta name='twitter:card' content='summary_large_image'>\n\t\t\t\t\t\t\t<meta name='twitter:site' content='" . __("Пушкице - ФОН Андерграунд") . "'>\n\t\t\t\t\t\t\t<meta name='twitter:creator' content='@puskice'>\n\t\t\t\t\t\t\t<meta name='twitter:domain' content='puskice.org'>\n\t\t\t\t\t\t\t<meta name='twitter:app:name:iphone' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t\t<meta name='twitter:app:name:ipad' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t\t<meta name='twitter:title' content='" . __("Квиз | Пушкице") . "'>\n\t\t\t\t\t\t\t<meta name='twitter:description' content='" . __("Квиз за ФОН-овце") . "'>\n\t\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, 'kviz' => $kviz, 'meta' => $meta);
$this->setLayout2($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);
$this->layout->center = View::make('frontend.content.kvizKraj', $data);
} catch (Exception $e) {
return App::abort(404);
}
}
}
示例7: 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');
}
}