title: Laravel how to access Auth in javascript file.
body: <p>In my <code>@yield('scripts')</code> section have a javascript call where I only show a button if the user is an admin. </p>
  
  <p>I want to put the javascript in my library because it gets used more than once. However Blade/php doesn't work when I try to include this section in a library <code>myApp.js</code></p>
  
  <p><strong>javascript section</strong></p>
  
  <pre><code>BootstrapDialog.show({
     title: 'Age Not Met',
   message: 'The attendee does not meet the age reguirement for this program.',
      type: BootstrapDialog.TYPE_WARNING,
   buttons: [
            @if (Auth::user()-&gt;hasRole('admin')||Auth::user()-&gt;hasRole('programmer'))
            {
                label: 'OVERIDE',
             cssClass: 'btn-danger',
               action: function(dialogItself){
                       checkbox.prop('checked', true);
  //...rest irrelevant
  </code></pre>
  
  <p>I tried to use a variable in my layout to replace the blade/php call but the variable is blank. Also I realized I can't just replace the blade with an <code>if(isAdmin)</code> because it's in a function parameter...How do I do get the button to appear only for the admin?.</p>
  
  <p><strong>in layout</strong>    </p>
  
  <pre><code>&lt;script&gt;
  var isAdmin = {{ (Auth::user()-&gt;hasRole('admin')||Auth::user()-&gt;hasRole('programmer')) }}
  &lt;/script&gt;
  </code></pre>