本文整理汇总了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') . '');
}
示例2: patch
public function patch($id, Request $request)
{
$topic = Topic::findOrFail($id);
$this->authorize('update-topic', $topic);
$topic->patch($request->all());
return response('', 200);
}
示例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');
}
示例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');
}
}
}
}
示例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);
}
示例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;
}
}
示例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('/');
}
示例8: addTag
public function addTag(Request $request, $topicId)
{
$topic = Topic::findOrFail($topicId);
$topic->addTag(Tag::findOrFail($request->input('tag')));
return redirect("/topics/{$topicId}");
}
示例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');
}