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


PHP Topic::findOrFail方法代码示例

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


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

示例1: editTopic

 public function editTopic($id, UpdateTopicRequest $request)
 {
     $topic = Topic::findOrFail($id);
     $topic->update(['title' => $request->input('title'), 'body' => $request->input('body'), 'important' => $request->input('important'), 'topic_close' => $request->input('topic_close')]);
     flash()->success('Udało Ci się edytować temat o ID <b>' . $id . '</b>!');
     return redirect('/forum/' . $request->input('head') . '/' . $request->input('sec') . '');
 }
开发者ID:AdrianKuriata,项目名称:projekt,代码行数:7,代码来源:TopicController.php

示例2: patch

 public function patch($id, Request $request)
 {
     $topic = Topic::findOrFail($id);
     $this->authorize('update-topic', $topic);
     $topic->patch($request->all());
     return response('', 200);
 }
开发者ID:mattstauffer,项目名称:suggestive,代码行数:7,代码来源:TopicsController.php

示例3: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $this->validate($request, ['name' => 'required', 'title' => 'required', 'description' => 'required']);
     $topic = Topic::findOrFail($id);
     $topic->update($request->all());
     \Session::flash('success', $topic->name . ' topic is successfully updated.');
     return redirect('topics');
 }
开发者ID:phpclub,项目名称:GA-Exam,代码行数:14,代码来源:TopicsController.php

示例4: showTopic

 public function showTopic($id)
 {
     $topic = Topic::findOrFail($id);
     $replys = Reply::where('topic_id', $id)->paginate(20);
     if (!\Auth::guest() && \Auth::user()->isAdmin() || !\Auth::guest() && \Auth::user()->isMod()) {
         if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
             return view('forum.showTopic', compact('topic', 'replys'));
         } else {
             \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
             return view('forum.showTopic', compact('topic', 'replys'));
         }
     } else {
         if ($topic->forumSection->forumHead['forOrg'] == 0 && $topic->forumSection->forumHead['forBiz'] == 0) {
             if (\Auth::guest()) {
                 return view('forum.showTopic', compact('topic', 'replys'));
             }
             if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
                 return view('forum.showTopic', compact('topic', 'replys'));
             } else {
                 \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
                 return view('forum.showTopic', compact('topic', 'replys'));
             }
         } else {
             if (!\Auth::guest() && $topic->forumSection->forumHead['forOrg'] == \Auth::user()->queryLeaderHeads()) {
                 if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
                     return view('forum.showTopic', compact('topic', 'replys'));
                 } else {
                     \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
                     return view('forum.showTopic', compact('topic', 'replys'));
                 }
             } elseif (!\Auth::guest() && $topic->forumSection->forumHead['forOrg'] == \Auth::user()->queryMemberHeads()) {
                 if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
                     return view('forum.showTopic', compact('topic', 'replys'));
                 } else {
                     \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
                     return view('forum.showTopic', compact('topic', 'replys'));
                 }
             } elseif (!\Auth::guest() && $topic->forumSection->forumHead['forBiz'] == \Auth::user()->queryBmemberHeads()) {
                 if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
                     return view('forum.showTopic', compact('topic', 'replys'));
                 } else {
                     \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
                     return view('forum.showTopic', compact('topic', 'replys'));
                 }
             } elseif (!\Auth::guest() && $topic->forumSection->forumHead['forBiz'] == \Auth::user()->queryBleaderHeads()) {
                 if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
                     return view('forum.showTopic', compact('topic', 'replys'));
                 } else {
                     \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
                     return view('forum.showTopic', compact('topic', 'replys'));
                 }
             } else {
                 flash()->error('Nie masz dostępu do tego tematu!');
                 return redirect('/forum');
             }
         }
     }
 }
开发者ID:AdrianKuriata,项目名称:projekt,代码行数:58,代码来源:ForumController.php

示例5: store

 public function store($episodeId, Request $request)
 {
     if (!Auth::user()->isAdmin()) {
         abort(403);
     }
     $episode = Episode::findOrFail($episodeId);
     $topic = Topic::findOrFail($request->get('topic_id'));
     $episode->topics()->save($topic);
 }
开发者ID:mattstauffer,项目名称:suggestive,代码行数:9,代码来源:EpisodeScheduledTopicsController.php

示例6: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $topic = Topic::findOrFail($id);
     $input = array_except($request->input(), '_method');
     if ($topic->update($input)) {
         return $topic;
     } else {
         return $errors;
     }
 }
开发者ID:kikyous,项目名称:laravel,代码行数:17,代码来源:TopicController.php

示例7: delete

 public function delete(Request $request)
 {
     $target_id = $request->id;
     if ($target_id && is_numeric($target_id)) {
         $topic = Topic::findOrFail($target_id);
         $topic->delete();
         \Session::flash('flash_message', 'Topic successfully deleted!');
     } else {
         \Session::flash('flash_message', 'Topic delete failed! something went wrong.');
     }
     return redirect('/');
 }
开发者ID:shanonim,项目名称:itaema,代码行数:12,代码来源:TopicsController.php

示例8: addTag

 public function addTag(Request $request, $topicId)
 {
     $topic = Topic::findOrFail($topicId);
     $topic->addTag(Tag::findOrFail($request->input('tag')));
     return redirect("/topics/{$topicId}");
 }
开发者ID:jysperm,项目名称:labbs-laravel,代码行数:6,代码来源:TopicController.php

示例9: destroy

 public function destroy($id)
 {
     $topic = Topic::findOrFail($id);
     $this->authorOrAdminPermissioinRequire($topic->user_id);
     $topic->delete();
     Flash::success(lang('Operation succeeded.'));
     return redirect()->route('topics.index');
 }
开发者ID:yhbyun,项目名称:l5-forum,代码行数:8,代码来源:TopicsController.php


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