Level 55
@marcolino922 here
$product = new Items();
you define products as an object, not as array, so, you are not aable to use dot notation.try like so:
{{ optional(session('product'))->title }}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I would like to create a multi step form with validations, but the values are not stored in the inputs through the sessions.
In the controller I have:
use Illuminate\Support\Facades\Session;
My code at the moment is this:
public function addItemStep1(Request $request)
{
$product = $request->session()->get('product');
return view('admin.items.add', compact('product'))->with([
'page_name' => __('Add Item')
]);
}
public function storeNewItemStep1(Request $request)
{
$validatedData = $request->validate([
'title' => 'required',
'body' => 'required'
]);
if(empty($request->session()->get('product')))
{
$product = new Items();
$product->fill($validatedData);
$request->session()->put('product', $product);
} else {
$product = $request->session()->get('product');
$product->fill($validatedData);
$request->session()->put('product', $product);
}
return redirect('/');
}
The validations work, everything is ok, but unfortunately after sending the form the data just entered does not appear.
<input type="text" class="form-control @error('title') is-invalid @enderror" value="{{ Session::get('title') }}" name="title">
{{ session()->get('product.title') }}
Please or to participate in this conversation.