validate([ 'title' => 'nullable|string', 'body' => 'required|string', 'type' => 'in:text, image, video', ]); $content = $page->Contents()->create($validated); return response(['message' => 'created', 'data' => $content]); } /** * Display the specified resource. */ public function show(Content $content) { // } /** * Show the form for editing the specified resource. */ public function edit(Content $content) { } /** * Update the specified resource in storage. */ public function update(Request $request, Content $content) { // if($request->user_token != $content->Page->user_token){ return response('unauthorized', 403); } $validated = $request->validate([ 'body' => 'required|string', ]); $content->body = $validated['body']; $content->save(); return response(['message' => 'updated', 'data' => $content]); } /** * Remove the specified resource from storage. */ public function destroy(Content $content) { // } }