本文整理匯總了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