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


PHP Photo::orderBy方法代碼示例

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


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

示例1: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $recordsPerPage = 3;
     $offset = ($this->page - 1) * $recordsPerPage;
     $count = Photo::count();
     if ($this->page > 1) {
         $previousPage = $this->page - 1;
     } else {
         $previousPage = null;
     }
     if ($this->page * $recordsPerPage < $count) {
         $nextPage = $this->page + 1;
     } else {
         $nextPage = null;
     }
     $photos = Photo::orderBy('posted_date', 'desc')->skip($offset)->take($recordsPerPage)->get();
     //$previousUrl = action('PhotosController@index', ['page' => $previousPage]);
     //$nextUrl = action('PhotosController@index', ['page' => $nextPage]);
     if ($previousPage) {
         $previousUrl = url('photos/display/' . $previousPage);
     } else {
         $previousUrl = null;
     }
     if ($nextPage) {
         $nextUrl = url('photos/display/' . $nextPage);
     } else {
         $nextUrl = null;
     }
     return ['photos' => $photos, 'previousUrl' => $previousUrl, 'nextUrl' => $nextUrl];
 }
開發者ID:BobHumphrey,項目名稱:tumblr-photos,代碼行數:35,代碼來源:CreatePhotosPager.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return view('photos', ['photos' => Photo::orderBy('created_at', 'asc')->get()]);
 }
開發者ID:RahulVerlekar,項目名稱:PhotoGrab,代碼行數:9,代碼來源:PhotoController.php

示例3: date

    $date = date("Y-m-d");
    $heure = date("H:i:s");
    $iduser = Auth::user()->idutilisateur;
    $anecdote = new Anecdote();
    $anecdote->anecdote = $request->anecdote;
    $anecdote->idperle = $request->input('idperle');
    $anecdote->dateanecdote = $date;
    $anecdote->heureanecdote = $heure;
    $anecdote->idutilisateur = $iduser;
    if ($anecdote->save()) {
        return view('accueil_bootstrap');
    }
});
// Rècupere aléatoirement des photos dans la base de données afin de la afficher sur la page d'accueil (bandeau à droite)
Route::get('/photosaleatoires', function () {
    $photos = Photo::orderBy(DB::raw('RAND()'))->get();
    /* $photos= DB::table('photos')
       ->select(['nomphoto'])
       ->orderBy('RAND()');  */
    echo json_encode($photos);
});
// Affiche la page de consultation
Route::get('/consulter', function () {
    $perles = Perle::get();
    return view('consulter_perle');
});
/* --------------- FORMULAIRE DE CONSULTATION ------------------- */
// Affiche au format JSON de toutes les catégories
Route::get('/categoriesREST', function () {
    $categories = Categorie::get();
    echo json_encode($categories);
開發者ID:amato-impera,項目名稱:LesPerlesDuMonde,代碼行數:31,代碼來源:routes.php

示例4: index

 /**
  * Display view for homepage
  *
  * @param Photo $images
  * @return $this
  */
 public function index(Photo $images)
 {
     return view('welcome')->with('images', $images->orderBy('created_at', 'desc')->paginate(20));
 }
開發者ID:DefrostedTuna,項目名稱:php-image,代碼行數:10,代碼來源:PhotoController.php


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