Created
May 1, 2022 23:29
-
-
Save elishaukpong/e3a1b4379267433a438414c843740481 to your computer and use it in GitHub Desktop.
Simple example of DRY
This file contains 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
/** BEFORE DRY */ | |
<a href="{{route(sprintf('%s.templateLibrary.index', app()->getLocale()))}">Hello</a> | |
<a href="{{route(sprintf('%s.templateLibrary.index', app()->getLocale()))}">Hello 2</a> | |
<a href="{{route(sprintf('%s.templateLibrary.index', app()->getLocale()))}">Hello 3</a> | |
/** AFTER DRY */ | |
function getRouteString($route){ | |
return route(sprintf("%s.{$route}", app()->getLocale())); | |
} | |
<a href="{{getRouteString('templateLibrary.index')}}">Hello</a> | |
<a href="{{getRouteString('templateLibrary.index')}}">Hello 2</a> | |
<a href="{{getRouteString('templateLibrary.index')}}">Hello 3</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment