本文整理汇总了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'));
}
示例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 () {