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


PHP Topic::with方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $topics = Topic::with('user')->orderBy('created_at', 'desc')->paginate(10);
     $data = $topics->map(function ($item, $key) {
         $item->postsCount;
         return $item;
     });
     return response()->json(['topics' => $data])->header('X-Page-Total', ceil($topics->total() / 10))->header('X-Page', $topics->currentPage());
 }
开发者ID:uTosTan,项目名称:codesamples,代码行数:14,代码来源:TopicController.php

示例2: show

 /**
  * Show the topic
  *
  * @param  Request  $request
  * @return Response
  */
 public function show(Request $request, $id)
 {
     $topic = App\Topic::with('comment', 'comment.user')->where('id', $id)->first();
     if (empty($topic) || $topic->status == -1) {
         if (Auth::guest() || !Auth::user()->is_admin()) {
             return view('errors.topic404');
         }
     }
     return view('topic.show', ['topic' => $topic]);
 }
开发者ID:theballkyo,项目名称:zgm-mc-web,代码行数:16,代码来源:TopicController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (Auth::check()) {
         $actu = Actualite::orderBy('id', 'desc')->first();
         $topics = Topic::with('posts')->orderBy('created_at', 'desc')->take(5)->get();
         //$postPerTopic =
         $userLevel = $this::checkLevel();
         return view('index', ['topics' => $topics, 'actu' => $actu, 'level' => $userLevel]);
     } else {
         return view('index');
     }
 }
开发者ID:prudywsh,项目名称:tpe,代码行数:17,代码来源:IndexController.php

示例4: index

 /**
  * List all of the topics from a given board
  *
  * @return \Illuminate\Request
  */
 public function index()
 {
     $topics = Topic::with('topic_id', 'user_id');
     return view('topics.index', compact('topics'));
 }
开发者ID:larabb,项目名称:larabb,代码行数:10,代码来源:TopicsController.php

示例5: delete_topic

 public function delete_topic($id)
 {
     $topic = Topic::with('comments')->find($id);
     if (Auth::user()->id == $topic->user_id) {
         $topic->active = 0;
         $topic->save();
         foreach ($topic->comments as $comment) {
             $comment->active = 0;
             $comment->save();
         }
     }
     return redirect('home');
 }
开发者ID:JosephsPlace,项目名称:Laravel-Forum,代码行数:13,代码来源:HomeController.php

示例6: forSubject

 /**
  * Get all of the topics for a given subject.
  *
  * @param  Subject  $subject
  * @return Collection
  */
 public function forSubject($subject_id)
 {
     return Topic::with('knowledgeunits')->where('topics.subject_id', $subject_id)->orderBy('created_at', 'asc')->get();
 }
开发者ID:nouzun,项目名称:gamification,代码行数:10,代码来源:TopicRepository.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //$topics = Topic::paginate($this->nbrPerPage);
     $topics = Topic::with('user', 'posts')->orderBy('created_at', 'desc')->get();
     return view('forum.index', ['topics' => $topics]);
 }
开发者ID:prudywsh,项目名称:tpe,代码行数:11,代码来源:TopicController.php


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