try adding session()->save() in the controller
Mar 21, 2021
2
Level 1
Session variable not available in Laravel Chart Class
Hi,
I'm trying to get session variable in class responsible for providing data to chartisan and it's null. I can't find out why?
In controller I set session variable and would like to read it in Chart class. I'am using Laravel 8 and "consoletvs/charts": "7.*",
My code is below.
// Controler and function which generates view
if ($request->has('stopDateAssets'))
{
$stopDateAssets = request('stopDateAssets');
session(['stopDateAssets' => $stopDateAssets]);
} elseif ($request->session()->has('stopDateAssets')) {
$stopDateAssets = session('stopDateAssets');
} else {
$stopDateAssets = Carbon::now()->toDateString();
session(['stopDateAssets' => $stopDateAssets]);
}
// class TotalAssetsUSDChart extends BaseChart
$stopDateAssets = session('stopDateAssets');
Could you please explain me why session variable is null?
Please or to participate in this conversation.