Created
November 20, 2020 13:49
-
-
Save MarceauKa/d7a7e35c61f2cd97072973c81a24d2fb to your computer and use it in GitHub Desktop.
Laravel magic helpers
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
<?php | |
# In app/Helpers.php | |
# Helpers defined here are called with Laravel and Composer autoloading capabilities | |
/** | |
* User defined helpers | |
*/ | |
class Helpers | |
{ | |
public function in(int $minutes): \DateTimeInterface | |
{ | |
return now()->addMinutes($minutes); | |
} | |
} | |
# In my controllers or blade files | |
dd(in(10)); // Return the result of your helper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment