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


PHP Post::take方法代码示例

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


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

示例1: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     $work = Work::where('slug', $slug)->firstOrFail();
     $morePosts = Post::take(3)->orderBy("created_at", "desc")->get();
     $moreWorks = Work::where('slug', '!=', $work->slug)->take(3)->orderBy("created_at", "desc")->get();
     return view('works.show', compact("work", "moreWorks", "morePosts"));
 }
开发者ID:voidgraphics,项目名称:Void-Portfolio,代码行数:13,代码来源:WorksController.php

示例2: dashboard

 /**
  * Show the application dashboard screen to the superadmin.
  *
  * @return Response
  */
 public function dashboard()
 {
     $activeCount = User::where('active', '1')->count();
     $subscriberCount = User::where('role', 'subscriber')->count();
     $freelancerCount = User::where('role', 'freelancer')->count();
     $inactiveCount = User::where('active', '0')->count();
     $latestUsers = User::take(4)->latest()->get();
     $latestSubscribers = User::take(4)->where('role', 'subscriber')->latest()->get();
     $latestPosts = Post::take(4)->latest()->get();
     $latestPages = Page::take(4)->latest()->get();
     return view('superadmin.dashboard')->with('activeCount', $activeCount)->with('subscriberCount', $subscriberCount)->with('freelancerCount', $freelancerCount)->with('inactiveCount', $inactiveCount)->with('latestUsers', $latestUsers)->with('latestSubscribers', $latestSubscribers)->with('latestPosts', $latestPosts)->with('latestPages', $latestPages);
 }
开发者ID:JRizzle88,项目名称:wewillcode,代码行数:17,代码来源:DashboardController.php

示例3: getPosts

 public function getPosts(Request $request)
 {
     try {
         $session_token = $request->get('session_token');
         $index = $request->get('index', 1);
         $limit = 5;
         $offset = $index - 1;
         $posts = Post::take($limit)->offset($offset * $limit)->orderBy('created_at', 'DESC')->get();
         $data = [];
         $customer = SessionUtil::getCustomer($session_token);
         $timeAgo = new TimeAgo();
         foreach ($posts as $post) {
             $is_liked = DB::table('post_likes')->where('customer_id', $customer->id)->where('post_id', $post->id)->exists();
             $is_photo_post = $post->photo != null && $post->photo != "";
             $data[] = ['id' => $post->id, 'description' => $post->description, 'photo' => $post->photo, 'like_count' => $post->likes->count(), 'is_liked' => $is_liked, 'is_photo_post' => $is_photo_post, 'comment_count' => $post->comments->count(), 'customer_name' => $post->customer->display_name, 'ago' => $timeAgo->inWords($post->created_at)];
         }
         // sleep(2000);
         return Response::json(['status' => 1, 'message' => 'Success', 'data' => $data]);
     } catch (Exception $e) {
         return Response::json(['status' => 0, 'message' => $e->getMessage()]);
     }
 }
开发者ID:vampirethura,项目名称:modelvillage,代码行数:22,代码来源:PostApiController.php

示例4: index

 public function index()
 {
     $annonces = Post::take(6)->get();
     return view('index', compact('annonces'));
 }
开发者ID:atofa,项目名称:atofaVersionFinale,代码行数:5,代码来源:WelcomeController.php

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $posts = Post::take(4)->orderBy('id', 'desc')->get();
     return view('painel.postagens.postagens', compact('posts'));
 }
开发者ID:ronal2do,项目名称:stq001,代码行数:10,代码来源:PoController.php

示例6: index

 /**
  * Display the homepage content
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $posts = Post::take(5)->orderBy('created_at', 'desc')->get();
     $page = Page::where('title', 'home')->first();
     return view('welcome', compact('posts', 'page'));
 }
开发者ID:victorboissiere,项目名称:Synergie,代码行数:11,代码来源:WelcomeController.php

示例7: show

 /**
  * Display the specified resource.
  *
  * @param  \App\Post $Post
  * @return Response
  */
 public function show(Post $post)
 {
     $sidebarPosts = Post::take(10)->latest()->get();
     // single Post view
     return view('posts.show', compact('post'))->with('sidebarPosts', $sidebarPosts);
 }
开发者ID:JRizzle88,项目名称:wewillcode,代码行数:12,代码来源:PostsController.php


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