本文整理匯總了PHP中News::with方法的典型用法代碼示例。如果您正苦於以下問題:PHP News::with方法的具體用法?PHP News::with怎麽用?PHP News::with使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類News
的用法示例。
在下文中一共展示了News::with方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
public function index()
{
$page = Page::find(1);
$menuItems = Page::where('parent_id', 0)->get();
$news = News::with('user')->orderBy('created_at', 'desc')->first();
return View::make('front.pages.index')->with(['page' => $page, 'news' => $news, 'menuitems' => $menuItems]);
}
示例2: showSinglePressItem
public function showSinglePressItem($slug, $id)
{
$pressItem = News::with('catalog')->find($id);
if (!$pressItem || !$pressItem->isActive() || $pressItem->getSlug() != $slug) {
App::abort(404);
}
$previousPressItemId = News::active()->where('id', '<', $pressItem->id)->max('id');
$previousPressItem = News::find($previousPressItemId);
$nextPressItemId = News::active()->where('id', '>', $pressItem->id)->min('id');
$nextPressItem = News::find($nextPressItemId);
return View::make('about.press.single', compact('pressItem', 'previousPressItem', 'nextPressItem'));
}
示例3: index
public function index()
{
$page = Page::find(1);
$news = News::with('user')->orderBy('created_at', 'desc')->first();
return View::make('front.pages.index')->with(['page' => $page, 'news' => $news]);
}
示例4:
<?
/**
* TITLE: Новости
* AVAILABLE_ONLY_IN_ADVANCED_MODE
*/
?>
<?php
$news_list = News::with('meta.seo', 'meta.photo', 'meta.gallery.photos')->orderBy('published_at', 'DESC')->paginate(6);
?>
@extends(Helper::layout())
@section('style')
@stop
@section('content')
<div class="half-page">
<div class="page-full">
<div class="wrapper">
<div class="tabs-title">
<h1 class="us-title title-yellow"><span>{{ $page->seo->h1 }}</span></h1>
@include(Helper::layout('about-menu'),array('hidden'=>'news'))
</div>
</div>
<div class="us-news">
<ul class="news__list martop40">
@foreach($news_list as $news)
<li class="list__item">
<div class="wrapper">
<div class="page__left">
<h2 class="item__link">
{{ $news->meta->title }}
</h2>
<div class="item__date">