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


PHP Post::with方法代码示例

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


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

示例1: show

 public function show($postID)
 {
     $post = Cache::remember('post_' . $postID, 15, function () use($postID) {
         return Post::with('tags')->find($postID);
     });
     return self::makeResponse($post);
 }
开发者ID:vanhonit,项目名称:lazada,代码行数:7,代码来源:PostController.php

示例2: showPost

 public function showPost($slug, Request $request)
 {
     $post = Post::with('tags')->whereSlug($slug)->firstOrFail();
     $tag = $request->get('tag');
     if ($tag) {
         $tag = Tag::whereTag($tag)->firstOrFail();
     }
     return view($post->layout, compact('post', 'tag'));
 }
开发者ID:saviorZSC,项目名称:zsc_laravel,代码行数:9,代码来源:BlogController.php

示例3: getList

 public static function getList($count = 10)
 {
     try {
         return Post::with('user')->orderBy('public_date', 'DESC')->paginate($count);
     } catch (Exception $e) {
         Log::info('Post:getList(): ' . $e->getMessage());
         return array();
     }
 }
开发者ID:antonov-dev,项目名称:test_domycode,代码行数:9,代码来源:Post.php

示例4: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $post = Post::with(array('User' => function ($query) {
         $query->select('id', 'name');
     }))->find($id);
     if (!$post) {
         return Response::json(['error' => ['message' => 'Post does not exist']], 404);
     }
     // get previous joke id
     $previous = Post::where('id', '<', $post->id)->max('id');
     // get next joke id
     $next = Post::where('id', '>', $post->id)->min('id');
     return Response::json(['previous_joke_id' => $previous, 'next_joke_id' => $next, 'data' => $this->transform($post)], 200);
 }
开发者ID:ganeshkanawade,项目名称:laravel-setup,代码行数:20,代码来源:PostsController.php

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return $this->getResponse(Post::with(['author', 'comments', 'author.posts'])->get()->all());
 }
开发者ID:guduchango,项目名称:limoncello,代码行数:9,代码来源:PostsController.php

示例6: normalIndexData

 /**
  * Return data for normal index page
  *
  * @return array
  */
 protected function normalIndexData()
 {
     $posts = Post::with('tags')->where('published_at', '<=', Carbon::now())->where('is_draft', 0)->orderBy('published_at', 'desc')->simplePaginate(config('upload.posts_per_page'));
     return ['title' => config('upload.title'), 'subtitle' => config('upload.subtitle'), 'posts' => $posts, 'page_image' => config('upload.page_image'), 'meta_description' => config('upload.description'), 'reverse_direction' => false, 'tag' => null];
 }
开发者ID:saviorZSC,项目名称:zsc_laravel,代码行数:10,代码来源:BlogIndexData.php

示例7: index

 public function index()
 {
     $posts = Post::with('categories')->get();
     return $this->postTransformer->transformCollection($posts);
 }
开发者ID:xeeeveee,项目名称:Laravel-Transformers-Example,代码行数:5,代码来源:TransformerController.php

示例8: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $model = Post::with('tags')->get()->toArray();
     return response()->json(['error' => false, 'data' => ['posts' => $model, 'counts' => count($model)]], 200);
 }
开发者ID:liubo2055,项目名称:test-lazada,代码行数:10,代码来源:PostController.php


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