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') . '');
 }
 public function patch($id, Request $request)
 {
     $topic = Topic::findOrFail($id);
     $this->authorize('update-topic', $topic);
     $topic->patch($request->all());
     return response('', 200);
 }
Exemple #3
0
 /**
  * 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');
 }
 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');
             }
         }
     }
 }
 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);
 }
Exemple #6
0
 /**
  * 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;
     }
 }
Exemple #7
0
 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('/');
 }
 public function delete(Request $request)
 {
     //削除対象の$idを取得する
     $target_id = $request->id;
     //$idの形式が正しいかのチェック(注意:この部分は実際に使う場合はより厳密なチェックが必要)
     if ($target_id && is_numeric($target_id)) {
         //既存データ1件削除
         $topic = Topic::findOrFail($target_id);
         $topic->delete();
         //削除成功時のメッセージを表示
         \Session::flash('flash_message', 'Topic successfully deleted!');
     } else {
         //削除失敗時のメッセージを表示
         \Session::flash('flash_message', 'Topic delete failed! Because something went wrong.');
     }
     //一覧画面へリダイレクト
     return redirect('/');
 }
 public function addTag(Request $request, $topicId)
 {
     $topic = Topic::findOrFail($topicId);
     $topic->addTag(Tag::findOrFail($request->input('tag')));
     return redirect("/topics/{$topicId}");
 }
Exemple #10
0
 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');
 }