title: how to share the current url to facebook in laravel?
body: <p>I want to share the current URL of my website to the facebook , so i used facebook's sharer.php. Here is my share.php file which shows icons and link to the sharer.php </p>
  
  <pre><code>&lt;div class="social-buttons"&gt;
      &lt;a href="https://www.facebook.com/sharer/sharer.php?u={{ urlencode($url) }}"
         target="_blank"&gt;
         &lt;i class="fa fa-facebook-official"&gt;&lt;/i&gt;
      &lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am passing the url to the ($url) from my page through the code </p>
  
  <pre><code>&lt;?php
  
  use App\Http\Requests;
  use Illuminate\Http\Request;
  
  ?&gt;
  @include('share',['url' =&gt; 'www.google.com'])
  </code></pre>
  
  <p>This particular webpage i am sharing the URL from usually generate dynamic URL. So I change the code to </p>
  
  <pre><code>@include('share',['url' =&gt; 'Request::url()'])
  </code></pre>
  
  <p>so that i can share the dynamically created URL. The problem here is When i put <code>www.google.com</code> in place of url the POP UP box works fine and open up the facebook share. But when i use <code>['url' =&gt; 'Request::url()'])</code> the pop up box opens and close quickly , i tried to see the url and it was something like error. How do i fix this? is there any drawback in this approach ?</p>
  
  <p>Here is the script code </p>
  
  <pre><code>&lt;script src="https://code.jquery.com/jquery-2.2.0.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  
      var popupSize = {
          width: 780,
          height: 550
      };
  
      $(document).on('click', '.social-buttons &gt; a', function(e){
  
          var
              verticalPos = Math.floor(($(window).width() - popupSize.width) / 2),
              horisontalPos = Math.floor(($(window).height() - popupSize.height) / 2);
  
          var popup = window.open($(this).prop('href'), 'social',
              'width='+popupSize.width+',height='+popupSize.height+
              ',left='+verticalPos+',top='+horisontalPos+
              ',location=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1');
  
          if (popup) {
              popup.focus();
              e.preventDefault();
          }
  
      });
  &lt;/script&gt;
  </code></pre>