How to return back the full model object after create

Viewed 128

I have posts table containing id , name, status, desc, status is enum('complete','incomplete') when I create a new post like this:

CreatePostRequest contains:
'name' , 'desc'

// create method
public function __invoke(CreatePostRequest $request)
{ 
   $post = Post::create($request->validated());
   dd($post);
}
output:
  #attributes: array:10 [
    "name" => "test"
    "desc" => "desc"
  ]

How can make status return with object after created!

I know the way of megre_array, but I do not thing this is a good idea espleacly when I have a lot of columns in table!

So is there any other way to return full of elequent object!

1 Answers
Related