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

<?php
namespace App\Http\Controllers;
use App\Models\Page;
use Inertia\Inertia;
use Inertia\Response;
use Illuminate\Http\Request;
use Illuminate\Contracts\Auth\MustVerifyEmail;
class PageController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*/
public function create(Request $request): Response
{
return Inertia::render('RepositoryPage/Create', [
'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
'status' => session('status'),
]);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
$request->validate([
'pageTitle' => 'required|string|max:255',
'category' => 'required|exists:categories,id',
'introduction' => 'required|string',
]);
$page = Page::create([
'page_title' => $request->pageTitle,
'category_id' => $request->category,
'introduction' => $request->introduction,
]);
return response()->json([
'message' => 'Page created successfully!',
'page' => $page,
]);
}
/**
* Display the specified resource.
*/
public function show(Page $page)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Page $page)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Page $page)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Page $page)
{
//
}
}