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


PHP Post::with方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //User::create(['email' => 'test@test.fr', 'password' => Hash::make('test')]);
     //Auth::logout();
     $posts = Post::with('category')->Published()->get();
     return view('posts.index', compact('posts'));
 }
开发者ID:alexisAvenel,项目名称:portfolioLaravel,代码行数:12,代码来源:PostsController.php

示例2: getFeed

 public function getFeed($type = null)
 {
     $feed = App::make('feed');
     //$feed->setCache(60);
     $parsedown = new Parsedown();
     $parsedown->setMarkupEscaped(true);
     if (!is_null($type)) {
         $posts = Post::where('feed', $type)->with('user')->orderBy('created_at', 'desc')->take(20)->get();
     } else {
         $posts = Post::with('user')->orderBy('created_at', 'desc')->take(20)->get();
     }
     $pubDate = count($posts) == 0 ? date('Y-m-d H:i:s') : $posts[0]->created_at;
     $feed->title = 'rhofma.de - Blog';
     $feed->description = 'Web-Developer Blog';
     $feed->logo = asset('img/logo.svg');
     $feed->link = URL::to('/');
     $feed->setDateFormat('datetime');
     $feed->pubdate = $pubDate;
     $feed->lang = 'de';
     $feed->setShortening(true);
     $feed->setTextLimit(500);
     foreach ($posts as $post) {
         $feed->add($post->title, $post->user->name, URL::to($post->slug), $post->created_at, $text = $post->teaser, $parsedown->parse($post->content));
     }
     return $feed;
 }
开发者ID:rhofma,项目名称:rhofma.de,代码行数:26,代码来源:FeedService.php

示例3: getIndex

 public function getIndex()
 {
     $posts = Cache::remember('site.overboard', 60, function () {
         return Post::with('op', 'board', 'board.assets')->withEverything()->orderBy('post_id', 'desc')->take(75)->paginate(15);
     });
     return $this->view(static::VIEW_MULTIBOARD, ['posts' => $posts]);
 }
开发者ID:JEWSbreaking8chan,项目名称:infinity-next,代码行数:7,代码来源:MultiboardController.php

示例4: getData

 public function getData($id, $title, $kode)
 {
     $dateNow = Carbon::now();
     $kelasDosen = Perkuliahan::select('kodekelas')->where('nip', '=', $id)->get()->toArray();
     $data = array('dosen' => DB::table('dosen')->where('nip', $id)->first(), 'dosenProfile' => Dosen::where('nip', '=', Request::segment(3))->first(), 'kelas' => Mhskelas::with(array('mhs', 'perkuliahan', 'mk'))->where('nim', '=', $id)->get(), 'kelasDosen' => Perkuliahan::with(array('mk', 'dosen'))->where('nip', '=', $id)->get(), 'title' => $title, 'listPerkuliahan' => ['' => '-- Pilih kelas --'] + Mhskelas::select('matakuliah.namamk', 'mhskelas.kodekelas')->join('matakuliah', 'mhskelas.kodemk', '=', 'matakuliah.kodemk')->join('mahasiswa', 'mhskelas.nim', '=', 'mahasiswa.nim')->where('mahasiswa.nim', '=', $id)->lists('matakuliah.namamk', 'mhskelas.kodekelas'), 'perkuliahanDosen' => ['' => '-- Pilih kelas --'] + Perkuliahan::select('perkuliahan.kodekelas', 'matakuliah.namamk')->join('matakuliah', 'matakuliah.kodemk', '=', 'perkuliahan.kodemk')->where('perkuliahan.nip', '=', $id)->lists('matakuliah.namamk', 'perkuliahan.kodekelas'), 'grup' => AnggotaGrup::select('grup.nama', 'grup.kodekelas')->join('grup', 'grup.id', '=', 'anggota_grup.id_grup')->where('anggota_grup.nim', '=', $id)->get(), 'post' => Post::with(array('komentar', 'mhs', 'perkuliahan'))->where('creator', '=', $id)->get(), 'postKelas' => Post::with(array('komentar', 'mhs', 'perkuliahan'))->where('id_scope', '=', $kode)->get(), 'kelasMember' => Mhskelas::with('mhs')->where('kodekelas', '=', $kode)->get(), 'infokelas' => Perkuliahan::with('mk', 'dosen')->where('kodekelas', '=', $kode)->first(), 'tugasDosen' => Tugas::where('pengumpulan', '>=', $dateNow)->whereIn('kelas', $kelasDosen)->get(), 'pengumumanDosen' => Pengumuman::where('waktuaktif', '>=', $dateNow)->whereIn('kodekelas', $kelasDosen)->get());
     return $data;
 }
开发者ID:bayudarmantra,项目名称:collaborative,代码行数:7,代码来源:DosenPageController.php

示例5: show

 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     $user = Sentinel::findById($id);
     $activation = Activation::exists($user);
     $posts = Post::with(['thread', 'thread.category'])->where('user_id', $user->id)->orderBy('created_at', 'desc')->get();
     return view('admin.users.show', compact('user', 'activation', 'posts'));
 }
开发者ID:Kehet,项目名称:k-forum,代码行数:13,代码来源:AdminUsersController.php

示例6: index

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $posts = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->orderBy('created_at', 'desc')->take(4)->get();
     $mostPopular = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->take(4)->get();
     $communities = Community::all();
     $cities = City::all();
     return view('pages.home', ['posts' => $posts, 'mostPopular' => $mostPopular, 'communities' => $communities, 'cities' => $cities]);
 }
开发者ID:jakeboyles,项目名称:GuyBuy,代码行数:13,代码来源:HomeController.php

示例7: looks

 /**
  * Display all looks by User 
  *
  * @return Response
  */
 public function looks($userId)
 {
     if (!User::find($userId)) {
         throw new NotFoundHttpException('no user found');
     }
     $looks = Post::with(['location', 'brands', 'look', 'post_author', 'comments', 'comments.comment_author'])->where('user_id', $userId)->where('is_look', true)->get();
     return response()->json($looks);
 }
开发者ID:artsoroka,项目名称:shopdrobeapp,代码行数:13,代码来源:UserController.php

示例8: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $post = Post::with(['location', 'photos', 'brands', 'look', 'post_author', 'comments', 'comments.comment_author'])->where('id', $id)->get();
     if (!$post || !count($post)) {
         throw new NotFoundHttpException('no post found');
     }
     return response()->json($post);
 }
开发者ID:artsoroka,项目名称:shopdrobeapp,代码行数:14,代码来源:PostController.php

示例9: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($slug)
 {
     $tag = Tag::where('slug', $slug)->firstOrFail();
     $posts = Post::with('tags')->whereHas('tags', function ($q) use($tag) {
         $q->where('tag_id', $tag->id);
     })->orderBy('created_at', 'desc')->paginate(15);
     return view('tags.show', compact('tag', 'posts'));
 }
开发者ID:joaumg-deprecated,项目名称:joaumg_com,代码行数:14,代码来源:TagsController.php

示例10: index

 public function index()
 {
     $totallikes = Like::count();
     $totalposts = Post::count();
     $posts = Post::with('cat', 'likes')->paginate(config('app.posts_per_page'));
     $page = $posts->currentPage();
     $lastpage = $posts->lastPage();
     return view('index', compact('totallikes', 'totalposts', 'posts', 'page', 'lastpage', 'title'));
 }
开发者ID:majid-n,项目名称:cometdev,代码行数:9,代码来源:HomeController.php

示例11: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $req = Post::with('user')->with('category')->with('job')->orderBy('updated_at', 'desc');
     if ($request->has('filterBy')) {
         $req->where($request->get('filterBy') . '_id', $request->get('id'));
     }
     $posts = $req->get();
     return view('admin.posts.index', compact('posts'));
 }
开发者ID:e-noumene,项目名称:Back,代码行数:14,代码来源:PostsController.php

示例12: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Subreddit $subreddit, Post $post, Moderator $moderator, User $user)
 {
     //$posts = Post::with('user.votes')->get();
     $posts = Post::with('user.votes')->with('subreddit.moderators')->orderBy('created_at', 'desc')->get();
     //$ids = $posts->subreddit;
     $isModerator = false;
     //dd($ids);
     return view('home')->with('posts', $posts)->with('isModerator', $isModerator);
 }
开发者ID:ReyRodriguez,项目名称:laravel-reddit,代码行数:14,代码来源:HomeController.php

示例13: 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:canwonson,项目名称:myWeb,代码行数:9,代码来源:IndexController.php

示例14: index

 /**
  * Display a listing of the resource.
  *
  * @param Request $request
  * @return Response
  */
 public function index(Request $request)
 {
     if ($id = $request->get('tag')) {
         $tag = Tag::findOrFail($id);
         return $tag->posts()->with('tags')->get();
     } else {
         return Post::with('tags')->latest()->take(5)->get();
     }
 }
开发者ID:breethe,项目名称:laravel-board,代码行数:15,代码来源:ApiController.php

示例15: getDetail

 /**
  * Display single post
  */
 public function getDetail($id, $page)
 {
     $post = Post::with('get_category')->find($id);
     if ($page == 'unpublished') {
         return view('admin/post/detailPost', array('user' => $this->username, 'nav_post' => '', 'nav_list_post' => '', 'post' => $post, 'page' => $page));
     } elseif ($page == 'published') {
         return view('admin/post/detailPost', array('user' => $this->username, 'nav_post' => '', 'nav_pub_post' => '', 'post' => $post, 'page' => $page));
     }
 }
开发者ID:ndro,项目名称:New-GI-Website-Concept,代码行数:12,代码来源:PostController.php


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