/** * Store a newly created resource in storage. * * @return Response */ public function store($idForum, TopicRequest $request) { // $topic = new ForumTopic(); $post = new ForumPost(); $topic->setForumId($idForum); $topic->setTitre($request->input('topic_titre')); $topic->setNbVu(0); $topic->setNbPost(0); $topic->setVerrouille(false); $topic->setGenreId($request->input('topic_genre')); $post->setTexte($request->input('post_texte')); $post->setForumId($idForum); Auth::user()->topics()->save($topic); $post->setTopicId($topic->getId()); Auth::user()->posts()->save($post); $topic->setFirsPostId($post->getId()); $topic->setLastPostId($post->getId()); $topic->save(); return redirect('forum/' . $idForum . '/topic'); }