public function create(Request $request, $id)
{
$request->session()->flash('id',$id);
return view('off.news');
}
This flashes the id value which then is used by the store controller function.
If i go to the create page from the first page it passes -> $id
is flashed
The problem:
When i press back to the create page then press submit on create - >
nothing is passed to $id.
I only want it to stay in for one time (not persist).
How do i ensure that the user cant press back to go to the create page?
If you have values that you need to pass through from the create
resource method to the resource store
method then you should pass those values through the form, you should not use flash data for this. Flash data is useful for passing non-essential information between requests (e.g: success messages), it is not suitable for passing information that functionality is dependent on.
For example, your implementation could look something like this:
create
public function create(int $id)
{
return view('resource.create', ['resource_id' => $id]);
}
form.blade.php
<form>
...
<input type="hidden" name="resource_id" value="{{ $resource_id }}">
...
</form>
store
public function store(Request $request)
{
$id = $request->input('resource_id');
// ...
}