Created
November 7, 2017 08:02
-
-
Save juukie/06eea94543ebe845f52b7d621f735e1f to your computer and use it in GitHub Desktop.
Laravel social media url macro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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