-
-
Save adamhut/189ae7fb077f9a9673a40ff900f7da76 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