I am using Laravel on my backend. I am gathering data from my db and then display a string based on if the field is empty or not. I am using Jquery on my front end. After hours of hacking around I found a solution that works, but I am think there has to be a better way. Here is a snippet of my back end code.
if(Auth::check()) { $ user = User::find(Auth::user()->id); $ data['fname'] = $ user->fname; if (empty($ data['fname'])) { $ data['fname'] = "__empty"; } } return view('pages.index', $ data);
and here is the code on the front end
checkProfileImprovment(); function checkProfileImprovment(){ @if (Auth::check()) fname = "{{$ fname}}" if(fname != '__empty'){ $ ('#profile-improvement-header').hide(); } else{ $ ('#profile-improvement-header').show(); } @endif }