orderByRaw("CASE WHEN status = 'pending' THEN 0 ELSE 1 END") ->orderBy('created_at', 'asc') ->get(); $categories = Category::all(); return view('admin.post-approval', [ 'posts' => $posts, 'categories' => $categories ]); } public function approve($id) { $post = Post::find($id); $post->status_published = 'active'; $post->status = 'published'; try { $post->save(); alert()->success('Berhasil', 'Menyetujui Postingan'); return redirect()->back(); } catch (\Throwable $th) { alert()->error('Gagal', 'Menyetujui Postingan'); return redirect()->back(); } } public function reject($id) { $post = Post::find($id); $post->status = 'rejected'; try { $post->save(); alert()->success('Berhasil', 'Menolak Postingan'); return redirect()->back(); } catch (\Throwable $th) { alert()->error('Gagal', 'Menolak Postingan'); return redirect()->back(); } } }