当前位置: 首页>>代码示例>>PHP>>正文


PHP Posts::orderBy方法代码示例

本文整理汇总了PHP中app\Posts::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::orderBy方法的具体用法?PHP Posts::orderBy怎么用?PHP Posts::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Posts的用法示例。


在下文中一共展示了Posts::orderBy方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $allLocations = Marker_location::all();
     $allEvents = Events::orderBy('created_at', 'DESC')->get();
     $allPost = Posts::orderBy('created_at', 'DESC')->get();
     //getting all the post from post database table
     $allUserPhotos = PhotoMapImageUploader::orderBy('photoMapId')->get();
     return view('admin.index', compact('allLocations', 'allEvents', 'allPost', 'allUserPhotos'));
 }
开发者ID:np-patel,项目名称:exploreTasman,代码行数:14,代码来源:AdminController.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $order = 'DESC';
     if ($request->order) {
         $order = $request->order;
     }
     $data = Posts::orderBy('date', $order)->paginate(5);
     if ($request->ajax()) {
         return Response::json(View::make('part', array('posts' => $data))->render());
     }
     return View::make('index', array('posts' => $data));
 }
开发者ID:sstetsurin,项目名称:testdesk,代码行数:17,代码来源:PostsController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $allPost = Posts::orderBy('created_at', 'DESC')->get();
     //getting all the post from post database table
     $userInfo = \Auth::user();
     $allEvents = Events::orderBy('created_at', 'DESC')->take(2)->get();
     $allUserPhotos = PhotoMapImageUploader::orderBy('photoMapId', 'DESC')->take(6)->get();
     // $postId = $allPost->id;
     // $TotalComments = Comments::where('on_post', '5')->count();
     // dd($TotalComments);
     return view('home.index', compact('allPost', 'userInfo', 'allEvents', 'allUserPhotos'));
 }
开发者ID:np-patel,项目名称:exploreTasman,代码行数:17,代码来源:HomeController.php

示例4: index

 /**
  * Display a listing of the resource. This function is handling root request (localhost:8000)
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $posts = Posts::orderBy('created_at', 'desc')->get();
     // ako sakame del po del mozhe so paginate()
     // bidejkji vo baza chuvame samo ime na slika,
     foreach ($posts as $post) {
         // slika na post
         if ($post->post_picture) {
             $imgName = $post->post_picture;
             $imgData = base64_encode(File::get('uploads/posts/' . $imgName));
             $post->post_picture = $imgData;
         }
         // slika na user koj postiral
         $post->user = $post->author;
         // tuka smeniv
         $imgName = $post->user->profile_picture;
         if ($imgName != "") {
             $imgData = base64_encode(File::get('uploads/profile_pictures/thumbnails/' . $imgName));
         } else {
             $post->user->profile_picture = base64_encode(File::get('uploads/profile_pictures/profile_picture.png'));
         }
         $post->user->profile_picture = $imgData;
         // komentari
         $comments = $post->comments;
         // // zemi gi slikite na korisnicite koi komentirale
         // foreach ($comments as $comment) {
         //     $comment->user = User::find($comment->user_id);
         //     $imgName = $comment->user->profile_picture;
         //     if($imgName){
         //        $imgData = base64_encode(File::get('uploads/profile_pictures/' . $imgName));
         //    } else {
         //        $imgData = base64_encode(File::get('uploads/profile_pictures/profile_picture.png'));
         //    }
         //     $comment->user->profile_picture = $imgData;
         // }
         // $post->comments = $comments;
         // dodaj gi site likes na ovoj post vo response-ot samo kako brojka (poseben servis za koi useri :))
         $post->nComments = count($comments);
         $post->nLikes = count($post->likes);
         // za sekoj post, vo odnos na toa koj user e avtenticiran t.e. go napravil requestot, pushti mu
         // flagche dali vekje go lajknal postot ili ne, za da mozhe da se sredi soodvetno vo angular :)
         if (count(Likes::where('post_id', $post->id)->where('user_id', $request->user()->id)->get()) == 1) {
             // povekje e greshka
             $post->liked = true;
         } else {
             $post->liked = false;
         }
     }
     return response()->json(['posts' => $posts]);
     // return view('home')->withPosts($posts)->withUser($user);
 }
开发者ID:1993Dajana,项目名称:pet-care,代码行数:56,代码来源:PostController.php

示例5: viewCourse

 public function viewCourse($courseID)
 {
     $course = Courses::find($courseID);
     if (count($course) < 1) {
         return view('errors.404');
     }
     if (auth() && auth()->user() && User::find(auth()->user()->getAuthIdentifier())['admin'] >= ConstsAndFuncs::PERM_ADMIN) {
         $posts = Posts::where('CourseID', '=', $courseID)->orderBy('id', 'asc')->paginate(5);
         $newpost = Posts::orderBy('id', 'dsc')->take(5)->get()->toArray();
         return view('userindex')->with(['Posts' => $posts, 'newpost' => $newpost, 'paginateBaseLink' => '/course/' . $courseID]);
     } else {
         if ($course['Hidden'] == 1) {
             return view('errors.404');
         }
         $posts = Posts::where('CourseID', '=', $courseID)->where('Hidden', '=', 0)->orderBy('id', 'asc')->paginate(5);
         $newpost = Posts::orderBy('id', 'dsc')->where('Hidden', '=', 0)->take(5)->get()->toArray();
         return view('userindex')->with(['Posts' => $posts, 'newpost' => $newpost, 'paginateBaseLink' => '/course/' . $courseID]);
     }
 }
开发者ID:ngocdon0127,项目名称:kids,代码行数:19,代码来源:CoursesController.php

示例6: savePost

 public function savePost(Request $request)
 {
     if (!AuthController::checkPermission()) {
         return redirect('/');
     }
     $data = $request->all();
     $post = new Posts();
     if (array_key_exists('Hidden', $data) && $data['Hidden'] == 'on') {
         $post->Hidden = 1;
     } else {
         $post->Hidden = 0;
     }
     $post->CourseID = $data['CourseID'];
     $post->ThumbnailID = $data['ThumbnailID'];
     $post->Title = $data['Title'];
     $post->Description = $data['Description'];
     $post->NoOfFreeQuestions = $data['NoOfFreeQuestions'];
     switch ($data['ThumbnailID']) {
         case '1':
             // Plain Text
             $post->save();
             $post = Posts::orderBy('id', 'desc')->first();
             //Photo
             $file = $request->file('Photo');
             $post->Photo = 'Post_' . $data['CourseID'] . '_' . $post->id . "_-Evangels-English-www.evangelsenglish.com_" . "." . $file->getClientOriginalExtension();
             $file->move(base_path() . '/public/images/imagePost/', $post->Photo);
             $post->update();
             break;
         case '2':
             // Video
             $linkVideo = $data['Video'];
             $post->Video = PostsController::getYoutubeVideoID($linkVideo);
             $post->save();
             break;
     }
     $course = Courses::find($post->CourseID);
     $course->NoOfPosts++;
     $course->update();
     // Save Hashtag
     $rawHT = $data['Hashtag'];
     TagsController::tag($rawHT, $post->id);
     return redirect(route('admin.viewcourse', $post->CourseID));
 }
开发者ID:ngocdon0127,项目名称:kids,代码行数:43,代码来源:PostsController.php

示例7: viewCourse

 public function viewCourse($courseID)
 {
     $posts = Posts::where('CourseID', '=', $courseID)->orderBy('id', 'asc')->paginate(5);
     $newpost = Posts::orderBy('id', 'dsc')->take(5)->get()->toArray();
     return view('userindex')->with(['Posts' => $posts, 'newpost' => $newpost, 'paginateBaseLink' => '/course/' . $courseID]);
 }
开发者ID:kevinhoa95,项目名称:kids,代码行数:6,代码来源:CoursesController.php

示例8: show

 public function show()
 {
     $posts = Posts::orderBy('created_at', 'desc')->paginate(3);
     return view('home')->with('posts', $posts);
 }
开发者ID:austin43,项目名称:personal-site,代码行数:5,代码来源:Home.php

示例9: blog

 public function blog()
 {
     $posts = Posts::orderBy('id', 'desc')->paginate(5);
     return view('page.blog')->with('posts', $posts);
 }
开发者ID:draaslan,项目名称:codeman,代码行数:5,代码来源:PageController.php

示例10: viewNewestPosts

 public function viewNewestPosts()
 {
     //        $posts = Posts::take(5)->skip(0)->get()->toArray();
     $Posts = Posts::orderBy('id', 'desc')->paginate(5);
     $newpost = Posts::orderBy('visited', 'dsc')->take(5)->get();
     $paginateBaseLink = '/';
     // dd($newpost);
     // dd($Posts);
     // dd($Posts->toArray());
     return view('userindex')->with(compact(['Posts', 'newpost', 'paginateBaseLink']));
 }
开发者ID:kevinhoa95,项目名称:e-learning,代码行数:11,代码来源:PostsController.php

示例11: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $admin_messages = \App\AdminMessages::where('read', '=', 0);
     $data = array('active_nav' => $this->active_nav, 'total_users' => \App\User::all()->count(), 'logged_in' => \App\User::where('logged_in', '=', 1)->count(), 'total_categories' => \App\categories::count(), 'total_posts' => \App\Posts::all()->count(), 'latest_users' => \App\User::orderBy('created_at', 'ASC')->limit(10)->get(), 'latest_posts' => \App\Posts::orderBy('created_at', 'ASC')->limit(10)->get(), 'unread_admin_messages' => $admin_messages->count(), 'new_users_month' => \App\User::getFromDate(date('y-m-0'))->count(), 'new_users_week' => \App\User::getFromDate(date('y-m-d', strtotime('-7 day')))->count(), 'new_users_day' => \App\User::getFromDate(date('y-m-d', strtotime('-1 day')))->count(), 'new_posts_month' => \App\Posts::getFromDate(date('y-m-0'))->count(), 'new_posts_week' => \App\Posts::getFromDate(date('y-m-d', strtotime('-7 day')))->count(), 'new_posts_day' => \App\Posts::getFromDate(date('y-m-d', strtotime('-1 day')))->count(), 'admin_messages' => $admin_messages->get());
     return view('includes/admin/home')->with($data);
 }
开发者ID:steakyfask,项目名称:ShareStuff,代码行数:11,代码来源:AdminHomeController.php

示例12: index

 public function index()
 {
     $post = Posts::orderBy('id', 'dsc')->take(3)->get();
     return view('mainpage')->with(compact('post'));
 }
开发者ID:kevinhoa95,项目名称:e-learning,代码行数:5,代码来源:PageController.php


注:本文中的app\Posts::orderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。