public function store(Request $request) { $category = Category::findOrFail($request->parent_id); $this->authorize('laraboard::board-create', $category); $this->validate($request, ['name' => 'required|max:255', 'body' => 'max:255']); $board = new Post(); $board->name = $request->name; $board->body = $request->body; $board->type = 'Board'; $board->user_id = \Auth::user()->id; $board->save(); $board->makeChildOf($category); return redirect()->route('board.show', [$board->slug, $board->name_slug])->with('success', 'Board created successfully.'); }
public function store(Request $request) { $board = Board::findOrFail($request->parent_id); $this->authorize('laraboard::thread-create', $board); $this->validate($request, ['name' => 'required|max:255', 'body' => 'required|max:4000']); $post = new Post(); $post->name = $request->name; $post->body = $request->body; $post->type = 'Thread'; $post->user_id = \Auth::user()->id; $post->save(); $post->makeChildOf($board); $thread = Thread::findOrFail($post->id); return redirect()->route('thread.show', [$thread->board->category->slug, $thread->board->slug, $thread->slug, $thread->name_slug]); }
/** * put your comment there... * * @param Request $request * @return {\Illuminate\Http\RedirectResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Http\RedirectResponse} */ public function store(Request $request) { $this->authorize('laraboard::category-create'); $this->validate($request, ['name' => 'required|max:255', 'body' => 'max:255']); // category names must be unique if (Category::whereName(strip_tags($request->name))->count() > 0) { return redirect()->back()->withInput()->with('danger', 'Category names must be unique.'); } $category = new Post(); $category->name = $request->name; $category->body = $request->body; $category->type = 'Category'; $category->user_id = \Auth::user()->id; $category->save(); return redirect()->route('forum.index')->with('success', 'Category created successfully.'); }