I'm trying to pass variable $cMonth to my view. I tried looping it using foreach even if its a single valued data and error still says undefined variable .. I tried dd($cMonth) and the correct output is shown.
This is a snippet of my controller.
$cMonth = date("F", mktime(0, 0, 0, $month, 1));
return view('admin.request',compact('showData','cMonth', 'year'));
In view, I am calling cMonth like this --
{{ ($cMonth) }}
$cMonthinside of anifstatement or other loop/conditional? Try sharing your entire controller and view code. Also, you don't need the parentheses around the variable when displaying it.{{ $cMonth }}is just fine.{{ ($cMonth) }}in the proper blade view file? I mean you're trying to access the viewadmin.request, kindly double check if you have placed that code inside this blade file{{ $cMonth }}?