get()->sortByDesc('created_at')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view("create_thread"); } /** * Show the form for editing the specified resource. * * @param \App\Thread $thread * @return \Illuminate\Http\Response */ public function edit(Thread $thread) { return view("edit")->withThread($thread); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $thread = new Thread; $thread->thread_title = $request->thread_title; $thread->thread_creator_id = $request->user_id; $thread->save(); } /** * Display the specified resource. * * @param integer $id * - A thread ID * @return \Illuminate\Http\Response */ public function show(int $id) { $selected_thread = new ThreadsCollection(Thread::with("posts")->get()->where("id", $id)); return $selected_thread; } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Thread $thread * @return \Illuminate\Http\Response */ public function update(Request $request, Thread $thread) { $thread->thread_title = $request->thread_title; $thread->save(); } /** * Remove the specified resource from storage. * * @param \App\Thread $thread * @return \Illuminate\Http\Response */ public function destroy(Thread $thread) { $thread->delete(); } }