public function share(Request $request)
{
return array_merge(parent::share($request), [
'darkMode' => !!$request->user()->dark_mode,
]);
}
So the code above is saying "use darkMode" once a user is logged in. The issue is, if a user is NOT logged in it comes back as NULL. How do I set a default value if it comes back as null (the default would be "false")
What about:
public function share(Request $request)
{
return array_merge(parent::share($request), [
'darkMode' => Auth::check() ? Auth::user()->dark_mode : false,
]);
}