Level 10
If the codes are in the same function it should work as it is.
Otherwise replace this line
dd($page->id);
with this
$page = Page::find($page->id);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
$i=1;
$page = page::create([
'title'=> $request->title,
'discretion'=> $this->is_null($request->discretion,$request->title),
'keyword'=>$this->is_null($request->keyword,$request->title),
'position'=> $this->is_null($request->position,'2'),
'status'=> $this->is_null($request->status,'0'),
'pageindex'=> $this->is_null($request->pageindex,'0'),
'parents'=> $this->is_null($request->parents,'0'),
'pagetitle'=> $request->pagetitle,
'pageurl'=> $this->call_url($request->pageurl)
]);
dd($page->id); // this function working
$Pangecontents = Pangecontents::create([
'content'=> $request->content,
'pages_id'=> $page->id, // here can't work
'orderby'=> '12'
]);
$page->content=$Pangecontents;
return response()->json($page,201);
Please or to participate in this conversation.