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