Any ideas how can I access $datainsert array in my blade template? My project is on Laravel 8.
This is the array:
$datainsert = array(
'website' => 'john.com',
'name' => 'John Smith'
);
I'm trying with the following way but I don't know how to use that data in the blade file
return Redirect()->back()
->with('success', 'Successfully Inserted')
->with($datainsert);
I tried this in my blade file: (but it didn't worked)
{{ $datainsert['name'] }}
Any ideas how to do it?
CodePudding user response:
When you use with() with redirect()->back(), the value of the $var is not accessible through {{ $var }} but is accessible through {{ session('var') }}
Use
session('var')
session()->has('var')
CodePudding user response:
send array in with()
return Redirect()->back()
->with(['success' => 'Successfully Inserted', 'datainsert' => $datainsert]);