當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Posts::latest方法代碼示例

本文整理匯總了PHP中app\Posts::latest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Posts::latest方法的具體用法?PHP Posts::latest怎麽用?PHP Posts::latest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Posts的用法示例。


在下文中一共展示了Posts::latest方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $posts = Posts::latest()->simplePaginate(5);
     return view('posts.index', compact('posts'));
 }
開發者ID:Appsbender,項目名稱:blog-laravel,代碼行數:10,代碼來源:PostsController.php

示例2: function

<?php

Route::get('/', ['as' => 'welcome', function () {
    $posts = \App\Posts::latest()->get();
    // dd($posts);
    return view('selection', compact('posts'));
}]);
Route::get('/realizacoes', ['as' => 'realizacoes', function () {
    $posts = \App\Posts::where('tipo', '!=', 'historia')->where('tipo', '!=', 'NULL')->latest()->get();
    $titulo = 'Realizações';
    $rand = array_rand(["#f77985" => "saude", "#be1039" => "educacao", "#69b843" => "infra", "#f87e3a" => "cidadania", "#2a9fe0" => "meio", "#ad4b9e" => "esporte"]);
    return view('templates.realizacoes', compact('posts', 'rand', 'titulo'));
}]);
Route::get('/download', 'PagesController@getDownload');
Route::get('jovem', 'PagesController@jovem');
Route::get('mulher', 'PagesController@mulher');
Route::get('geral', 'PagesController@geral');
Route::get('idoso', 'PagesController@idoso');
Route::get('/seminario', ['as' => 'seminario', function () {
    $rand = array_rand(["#f77985" => "saude", "#be1039" => "educacao", "#69b843" => "infra", "#f87e3a" => "cidadania", "#2a9fe0" => "meio", "#ad4b9e" => "esporte"]);
    return view('templates.pseminario', compact('rand'));
}]);
Route::get('/saude', 'SaudeController@index');
Route::get('/educacao', 'EspController@index');
Route::get('/infraestrutura', 'InfraController@index');
Route::get('/cidadania', 'CidadaniaController@index');
Route::get('/meioambiente', 'MeioController@index');
Route::get('/esporte', 'EsporteController@index');
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', ['as' => 'logout', function () {
開發者ID:ronal2do,項目名稱:stq001,代碼行數:31,代碼來源:routes.php


注:本文中的app\Posts::latest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。