本文整理汇总了PHP中News::paginate方法的典型用法代码示例。如果您正苦于以下问题:PHP News::paginate方法的具体用法?PHP News::paginate怎么用?PHP News::paginate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类News
的用法示例。
在下文中一共展示了News::paginate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$page = 1;
if (isset($_GET['page'])) {
$page = $_GET['page'];
}
$news = News::paginate("news.published = true AND news.publish_at < NOW()", "news.publish_at DESC", $page, 10);
$this->assign("page", $news);
if (isset($_GET['rss'])) {
// We don't want to clear flash data
if (isset($this->site['flash'])) {
$_SESSION['flash'] = $this->site['flash'];
}
header("Content-Type: application/rss+xml");
$this->render("news/index.rss.tpl", true);
} else {
$this->title = "News Archive";
$this->render("news/index.tpl");
}
}
示例2: news
public function news()
{
$news = News::paginate(4);
//分页显示
return View::make('home.news')->with('news', $news);
}
示例3: index
public function index()
{
$page = 1;
if (isset($_GET['page'])) {
$page = $_GET['page'];
}
$news = News::paginate(null, "news.publish_at DESC", $page, 20);
$this->assign("page", $news);
$this->title = "News";
$this->render("news/index.tpl");
}
示例4: newsEdit
public function newsEdit()
{
$news = News::paginate(10);
return View::make('admin.news-edit')->with('news', $news);
}
示例5: function
}
return View::make('catalog', ['categories' => $categories, 'products' => $products]);
});
Route::get('/catalog/categories/{alias}', function ($alias = null) {
$categories = Category::where('parent_id', 0)->get();
$category = Category::where('alias', $alias)->firstOrFail();
$products = Product::where('category_id', $category->id)->orderBy('updated_at', 'desc')->paginate(6);
return View::make('catalog', ['categories' => $categories, 'category' => $category, 'products' => $products]);
});
Route::get('/catalog/products/{alias}', function ($alias = null) {
$categories = Category::where('parent_id', 0)->get();
$product = Product::where('alias', $alias)->firstOrFail();
return View::make('product', ['categories' => $categories, 'product' => $product]);
});
Route::get('/news', function () {
$news = News::paginate(10);
return View::make('news', ['news' => $news]);
});
Route::match(array('get', 'post'), '/contacts', function () {
if (Request::isMethod('post')) {
// send email
Mail::send('emails.contact', Input::all(), function ($message) {
$message->from(Input::get('email'), Input::get('name'));
$message->to('danny_kent@mail.ru')->subject('Message from bumagi.by');
});
}
return View::make('contacts');
});
Route::get('cart/order', 'CartController@order');
Route::resource('cart', 'CartController', array('only' => array('index', 'store', 'destroy')));
// Confide routes