Can you show the code for validateThread()?
Sep 22, 2020
8
Level 14
How to include user id in $validated create?
I have this store method right now but the create functionality is kind of long, I would like to reduce it to just one line by passing the $validated to create. But the problem is that it doesn't include the user id. Any ideas how this might be solved?
public function store(Request $request)
{
$validated = $this->validateThread();
$thread = Thread::create([
'user_id' => auth()->id(),
'title' => $request->title,
'channel_id' => $request->channel_id,
'body' => $request->body,
]);
}
Would be really nice if this could be just one line.
public function store(Request $request)
{
$validated = $this->validateThread();
$thread = Thread::create($validated);
}
But the $validated doesn't include the user_id :(
Please or to participate in this conversation.