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


PHP Topic::find方法代码示例

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


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

示例1: detail

 public function detail($topic_id)
 {
     $topic = Topic::find($topic_id);
     if (!$topic) {
         return redirect()->guest('');
     }
     return view('webboarddetail', ['topic' => $topic, 'channels' => Channel::all(), 'user' => Auth::user()]);
 }
开发者ID:JesadaMTK,项目名称:issara,代码行数:8,代码来源:WebBoardController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $topic = Topic::find($id);
     $topic->content = $request->content;
     $topic->title = $request->title;
     $topic->save();
     return Redirect::action('TopicController@show', ['id' => $id]);
 }
开发者ID:prudywsh,项目名称:tpe,代码行数:15,代码来源:TopicController.php

示例3: add_topic_edit

 public function add_topic_edit(Request $request)
 {
     $topic = Topic::find($request->input('topic_id'));
     $topic->timestamps = false;
     $topic->opening_post = $request->input('opening_post');
     $topic->op_edited_at = date('Y-m-d H:i:s');
     $topic->save();
     return redirect('comment/' . $topic->id);
 }
开发者ID:JosephsPlace,项目名称:Laravel-Forum,代码行数:9,代码来源:HomeController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['ip' => 'required|ip', 'content' => 'required', 'user_id' => 'required']);
     if ($comment = Comment::create($request->all())) {
         Topic::find($comment->topic_id)->increment('comments');
         return redirect()->route('bbs.topic.show', [$comment->topic_id]);
     } else {
         return redirect()->back()->withInput()->withErrors('发表回帖失败!');
     }
 }
开发者ID:suowei,项目名称:saoju,代码行数:15,代码来源:CommentController.php

示例5: showPosts

 public function showPosts($id)
 {
     $topic = Topic::find($id);
     $posts = $topic->posts_paginated;
     $data = $posts->map(function ($item, $key) {
         $item->user = User::find($item->user_id);
         $item->user->postsCount;
         return $item;
     });
     return response()->json(['posts' => $data])->header('X-Page-Total', ceil($posts->total() / 10))->header('X-Page', $posts->currentPage());
 }
开发者ID:uTosTan,项目名称:codesamples,代码行数:11,代码来源:TopicController.php

示例6: editTopic

 public function editTopic()
 {
     Input::merge(array_map('trim', Input::all()));
     $id = (int) Input::get('id');
     $topic = Topic::find($id);
     if ($topic->exists()) {
         $topic->title = ucwords(Input::get('val'));
         $topic->save();
     }
     return 1;
 }
开发者ID:nitin-prodigi,项目名称:mesa,代码行数:11,代码来源:TopicController.php

示例7: createOrDelete

 public function createOrDelete($id)
 {
     $topic = Topic::find($id);
     if (Favorite::isUserFavoritedTopic(auth()->user(), $topic)) {
         auth()->user()->favoriteTopics()->detach($topic->id);
     } else {
         auth()->user()->favoriteTopics()->attach($topic->id);
         Notification::notify('topic_favorite', auth()->user(), $topic->user, $topic);
     }
     Flash::success(lang('Operation succeeded.'));
     return redirect()->route('topics.show', $topic->id);
 }
开发者ID:yhbyun,项目名称:l5-forum,代码行数:12,代码来源:FavoritesController.php

示例8: createOrDelete

 public function createOrDelete($id)
 {
     $topic = Topic::find($id);
     if (Favorite::isUserFavoritedTopic(Auth::user(), $topic)) {
         Auth::user()->favoriteTopics()->detach($topic->id);
     } else {
         Auth::user()->favoriteTopics()->attach($topic->id);
         Notification::notify('topic_favorite', Auth::user(), $topic->user, $topic);
     }
     flash()->success('hello!', lang('Operation succeeded.'));
     return Redirect::route('topics.show', $topic->id);
 }
开发者ID:stevejobsii,项目名称:phphub-laravel5.1,代码行数:12,代码来源:FavoritesController.php

示例9: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $topic = Topic::find($id, ['id', 'title', 'user_id', 'ip', 'content', 'created_at']);
     $topic->load(['user' => function ($query) {
         $query->select('id', 'name');
     }]);
     $comments = Comment::withTrashed()->select('user_id', 'ip', 'content', 'deleted_at', 'created_at')->where('topic_id', $id)->orderBy('id')->paginate(100);
     $comments->load(['user' => function ($query) {
         $query->select('id', 'name');
     }]);
     return view('bbs.topic', ['topic' => $topic, 'comments' => $comments]);
 }
开发者ID:suowei,项目名称:saoju,代码行数:18,代码来源:TopicController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['body' => 'required']);
     $input = Input::all();
     $input['user_id'] = Auth::user()->id;
     Reply::create($input);
     $topic = Topic::find($input['topic_id']);
     $topic->last_reply_user_id = Auth::id();
     $topic->reply_count++;
     $topic->save();
     return Redirect::route('topics.show', [Input::get('topic_id')]);
 }
开发者ID:gentcys,项目名称:fzzt,代码行数:18,代码来源:RepliesController.php

示例11: store

 public function store(Request $request)
 {
     $input = $request->all();
     $input['detail'] = delFontInline(delScriptTag($input['detail']));
     $comment = Comment::create($input);
     $content = Content::find($comment->content_id);
     $topic = Topic::find($comment->content_id);
     if ($content) {
         return redirect(route('content', $content->link));
     } elseif ($topic) {
         return redirect(route('read_topic', $topic->id));
     }
 }
开发者ID:JesadaMTK,项目名称:issara,代码行数:13,代码来源:ContentController.php

示例12: createOrDelete

 public function createOrDelete($id)
 {
     $topic = Topic::find($id);
     if (Attention::isUserAttentedTopic(Auth::user(), $topic)) {
         $message = lang('Successfully remove attention.');
         Auth::user()->attentTopics()->detach($topic->id);
     } else {
         $message = lang('Successfully_attention');
         Auth::user()->attentTopics()->attach($topic->id);
         Notification::notify('topic_attent', Auth::user(), $topic->user, $topic);
     }
     flash()->success('hello!', $message);
     return Redirect::route('topics.show', $topic->id);
 }
开发者ID:stevejobsii,项目名称:phphub-laravel5.1,代码行数:14,代码来源:AttentionsController.php

示例13: createOrDelete

 public function createOrDelete($id)
 {
     $topic = Topic::find($id);
     if (Attention::isUserAttentedTopic(auth()->user(), $topic)) {
         $message = lang('Successfully remove attention.');
         auth()->user()->attentTopics()->detach($topic->id);
     } else {
         $message = lang('Successfully_attention');
         auth()->user()->attentTopics()->attach($topic->id);
         Notification::notify('topic_attent', auth()->user(), $topic->user, $topic);
     }
     Flash::success($message);
     return redirect()->route('topics.show', $topic->id);
 }
开发者ID:yhbyun,项目名称:l5-forum,代码行数:14,代码来源:AttentionsController.php

示例14: edit

 public function edit(Request $request, $lecture_id, $subject_id, $topic_id, $knowledgeunit_id, $question_id)
 {
     $lecture = Lecture::find($lecture_id);
     $subject = Subject::find($subject_id);
     $topic = Topic::find($topic_id);
     $knowledgeunit = KnowledgeUnit::find($knowledgeunit_id);
     $question = Question::find($question_id);
     $data["nav"] = "<a href=\"" . url('/lectures/') . "\">" . $lecture->title . "</a> <span class=\"fa fa-chevron-right\"></span> <a href=\"" . url('/lectures/' . $lecture->id . '/subjects/') . "\">" . $subject->title . "</a> <span class=\"fa fa-chevron-right\"></span> <a href=\"" . url('/lectures/' . $lecture->id . '/subjects/' . $subject->id . '/topics/') . "\">" . $topic->title . "</a> <span class=\"fa fa-chevron-right\"></span> <a href=\"" . url('/lectures/' . $lecture->id . '/subjects/' . $subject->id . '/topics/' . $topic->id . '/knowledgeunits') . "\">" . $knowledgeunit->title . "</a> <span class=\"fa fa-chevron-right\"></span> <a href=\"" . url('/lectures/' . $lecture->id . '/subjects/' . $subject->id . '/topics/' . $topic->id . '/knowledgeunits/' . $knowledgeunit->id . '/questions') . "\">" . $question->title . "</a>";
     $data["lecture_id"] = $lecture_id;
     $data["subject_id"] = $subject_id;
     $data["topic_id"] = $topic_id;
     $data["knowledgeunit_id"] = $knowledgeunit_id;
     $data["question"] = $question;
     return view('question.edit', $data);
 }
开发者ID:nouzun,项目名称:gamification,代码行数:15,代码来源:QuestionController.php

示例15: topicAction

 public function topicAction()
 {
     $topic_id = (int) Input::get('id', 0);
     $currtopic = Topic::find($topic_id);
     if ($currtopic->exists()) {
         $menu_id = $currtopic->menu_id;
         $topicarr = Menu::find($menu_id)->topics()->orderBy('level', 'ASC')->orderBy('title', 'ASC')->get()->toArray();
         $topics = $this->clubarr($topicarr);
         $childtopics = $this->findTopics($topics, $topic_id);
         $allmenus = Menu::orderBy('level', 'ASC')->orderBy('title', 'ASC')->get()->toArray();
         $menus = $this->clubarr($allmenus);
         $articles = Menu::find($menu_id)->articles()->join('article_contents', 'article_contents.article_id', '=', 'articles.id')->whereIn('articles.topic_id', $childtopics)->get(['articles.*', 'article_contents.title'])->toArray();
         $viewarr = array('articles' => $articles, 'menus' => $menus, 'menuid' => $menu_id, 'topics' => $topics, 'topicid' => $topic_id);
         \View::share('pagetitle', $currtopic->title);
         return view('civil.menulist')->with($viewarr);
     }
 }
开发者ID:nitin-prodigi,项目名称:mesa,代码行数:17,代码来源:IndexController.php


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