init commit
All checks were successful
build-api-image / build (push) Successful in 51s

This commit is contained in:
Antonio Lopes dos Santos
2026-08-04 16:52:02 -03:00
commit afec302c3e
11594 changed files with 1636728 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
<?php
namespace App\Providers;
use App\Database\MySqlConnection;
use Illuminate\Database\Connection;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
Connection::resolverFor('mysql', function ($connection, $database, $prefix, $config) {
return new MySqlConnection($connection, $database, $prefix, $config);
});
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->loadMigrations();
}
private function loadMigrations()
{
$invalidContents = ['.', '..', '.gitkeep'];
$migrationsDir = database_path() . '/migrations/';
$migrationFilesPaths = $this->getMigrationFilesPaths(
$invalidContents,
$migrationsDir
);
$this->loadMigrationsFrom($migrationFilesPaths);
}
private function getMigrationFilesPaths($invalidContents, $currentDirectory, $paths = [])
{
$contents = opendir($currentDirectory);
while ($content = readdir($contents)) {
if (!in_array($content, $invalidContents)) {
$fullPath = $currentDirectory . $content;
if (is_dir($fullPath)) {
$paths = $this->getMigrationFilesPaths(
$invalidContents,
$fullPath . '/',
$paths
);
continue;
}
$paths[] = $fullPath;
}
}
return $paths;
}
}