Skip to content

Instantly share code, notes, and snippets.

@juukie
Created November 7, 2017 08:02
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save juukie/06eea94543ebe845f52b7d621f735e1f to your computer and use it in GitHub Desktop.
Laravel social media url macro
<?php
URL::macro('social', function ($name, $replacement = '#') {
return array_get([
'facebook' => 'https://www.facebook.com/mypage/',
'instagram' => 'https://www.instagram.com/mypage/',
'pinterest' => 'https://nl.pinterest.com/mypage/',
], $name), $replacement);
});
URL::social('facebook') // https://www.facebook.com/mypage/
URL::social('instagram') // https://www.instagram.com/mypage/
URL::social('unknown-social') // #
URL::social('unknown-social', '/contact') // /contact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment