Skip to content

Instantly share code, notes, and snippets.

@MarceauKa
Created November 20, 2020 13:49
Show Gist options
  • Save MarceauKa/d7a7e35c61f2cd97072973c81a24d2fb to your computer and use it in GitHub Desktop.
Save MarceauKa/d7a7e35c61f2cd97072973c81a24d2fb to your computer and use it in GitHub Desktop.
Laravel magic helpers
<?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