So, i have some categories. And in each category you can add posts.
But in form page for adding posts, how to get the value of that category i.e. of previous page?
This is my form:
<div class="container">
{!! Form::open(['action' => 'TopicController@store', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('title', 'Title') }}
{{ Form::text('title', '', ['class' => 'form-control', 'placeholder' => 'Title of the Post']) }}
</div>
<div class="form-group">
{{ Form::label('desc', 'Desc') }}
{{ Form::textarea('desc', '', ['class' => 'form-control', 'placeholder' => 'Description of the Post']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-default']) }}
{!! Form::close() !!}
</div>
Link in category page to form:
<a href="/topics/create">Create New Post</a>
Controller:
$this->validate($request, [
'title' => 'required',
'desc' => 'required',
])
$topic = new Topic;
$topic->topic_title = $request->input('title');
$topic->topic_body = $request->input('desc');
$topic->user_id = auth()->user()->id;
$topic->save();
return redirect('/')->with('Seccess', 'Topic Created');
show.blade.php contains link to this form page. But to get the id of the category page that is referring to this form??