Skip to content

Instantly share code, notes, and snippets.

@BinaryKitten
Created July 27, 2021 09:42
Show Gist options
  • Save BinaryKitten/41441343629e652efaea41cd88596488 to your computer and use it in GitHub Desktop.
Save BinaryKitten/41441343629e652efaea41cd88596488 to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class DbMacrosProvider extends ServiceProvider
{
public function boot(): void
{
collect(glob(database_path('macros/*/*.php'), GLOB_NOSORT))
->each(fn ($path) => require_once $path);
}
}
@BinaryKitten
Copy link
Author

I use this provider to autoload macros from single php files that live in database/macros/ folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment