How can I fix this error related to to controller?

I have a problem, thank you for your help. I want this to be done in the Store method when a person submits a question But it gives me an error that says: thread_id required ???!

  Subscribe::query()->create([
'thread_id'=>$thread->id,
'user_id' => auth()->user()->id
]);

This is the code for my Store method, which includes the subscribe model:

 public function store(Request $request,Thread $thread)
{
$request->validate([
'title' => ['required', 'min:3'],
'description' => ['required'],
'channel_id' => ['required'],
'thread_id' => ['required']
]);

Thread::create([
'title' => $request->title,
'description' => $request->description,
'user_id' => auth()->user()->id,
'channel_id' => $request->channel_id,
]);

Subscribe::query()->create([
'thread_id' => $thread->id,
'user_id' => auth()->user()->id
]);
return redirect('/');
}

This is also the code related to View

<form action="" method="post">
@csrf
<input type="hidden" name="thread_id" value="">

<div class=" container-fluid w-75 border border-secondary rounded shadow">
<div style="font-weight: bolder; font-size: large;" class=" my-3">فرم ارسال پرسش</div>
<div class="input-group mb-3">
<div class="input-group-prepend">

</div>
<input type="text" name="title" class="form-control" placeholder="موضوع" aria-label="Username" value=""
aria-describedby="basic-addon1">
</div>

<div class="input-group">
<textarea name="description" class="form-control" aria-label="With textarea" placeholder="متن پرسش"
style="height: 200px;"></textarea>
</div>


<div class="input-group mt-3 " style="direction: ltr;">
<select name="channel_id" class="custom-select" id="channel_id" >
<option selected disabled value="">انتخاب عنوان</option>
@foreach(AppModelsChannel::all() as $channel)
<option value=""></option>
@endforeach
</select>

</div>

<div class="my-3" style="width: 100px;">
<button class="btn btn-success" type="submit">ارسال</button>
</div>


</div>

the problem about this code on view

<input type="hidden" name="thread_id" value="">

also i sent the Thread model on view

 public function create(Thread $thread)
{
return view('answer-question.thread.thread-create',compact('thread'));
}

this is subcribe database enter image description here

from Newest questions tagged laravel-5 – Stack Overflow https://ift.tt/3qiz828
via IFTTT

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.