What exactly you want, you are pushing an array of data into a session right? and now you wanna use the array of data which is in session to your view . am i correct ?
session()->get( session_form_id ) Get session value in an array of the session id
Hi,
I am starting to use laravel and try to find my way around.
I have a multi step form on server side and I am saving the request() data in a session.
session()->put('session_form_id', request()->all());
This will give me a session similar to this: ( dd(session()->all() );
array:2 [▼
"_token" => "dwBxbjD5ts5ZlHVsPu5b9vLEdp47qyHAszaGhvfl"
"session_form_id" => array:1 [▼
"title" => "Some Title"
]
]
On my blade I want to pre-fill the value of the input fields if the session has saved data for that input.
As it is in the session already, I do not need to pass the session data to the view.
In the blade I tried to use all kind of approaches but cannot find out a good solution to check and display the Title if it isset.
{{ session()->get( 'session_form_id' )['title'] }}
{{ session()->get( 'session_form_id'['title'] ) }}
{{ session()->get( 'session_form_id', ['title'] ) }}
{{ session()->get( 'session_form_id', 'title' ) }}
get only accept one parameter for the id.
What works is:
@php
$data = session()->get( 'session_form_id' );
@phpend
{{ $data['title'] }}
This seems a bit for an overkill.
Do I overdue it? i still can pass the session data array directly to the view. Is there an easy way to access session data in an array like $_SESSION['session_form_id']['title']
Thank you!
I actually found what I was looking for:
session()->get( 'session_form_id.title')
Please or to participate in this conversation.