You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
1.8 KiB

  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\Page;
  4. use Inertia\Inertia;
  5. use Inertia\Response;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Contracts\Auth\MustVerifyEmail;
  8. class PageController extends Controller
  9. {
  10. /**
  11. * Display a listing of the resource.
  12. */
  13. public function index()
  14. {
  15. //
  16. }
  17. /**
  18. * Show the form for creating a new resource.
  19. */
  20. public function create(Request $request): Response
  21. {
  22. return Inertia::render('RepositoryPage/Create', [
  23. 'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
  24. 'status' => session('status'),
  25. ]);
  26. }
  27. /**
  28. * Store a newly created resource in storage.
  29. */
  30. public function store(Request $request)
  31. {
  32. $request->validate([
  33. 'pageTitle' => 'required|string|max:255',
  34. 'category' => 'required|exists:categories,id',
  35. 'introduction' => 'required|string',
  36. ]);
  37. $page = Page::create([
  38. 'page_title' => $request->pageTitle,
  39. 'category_id' => $request->category,
  40. 'introduction' => $request->introduction,
  41. ]);
  42. return response()->json([
  43. 'message' => 'Page created successfully!',
  44. 'page' => $page,
  45. ]);
  46. }
  47. /**
  48. * Display the specified resource.
  49. */
  50. public function show(Page $page)
  51. {
  52. //
  53. }
  54. /**
  55. * Show the form for editing the specified resource.
  56. */
  57. public function edit(Page $page)
  58. {
  59. //
  60. }
  61. /**
  62. * Update the specified resource in storage.
  63. */
  64. public function update(Request $request, Page $page)
  65. {
  66. //
  67. }
  68. /**
  69. * Remove the specified resource from storage.
  70. */
  71. public function destroy(Page $page)
  72. {
  73. //
  74. }
  75. }