當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。